poj2739 poj2100 尺取法基础(二)】的更多相关文章

都是很简单的题目 poj2739素数打表+单点推移 #include<iostream> #include<cstring> #include<cstdio> using namespace std; int cnt,n; ]; ] = {,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,…
题意:给你一个数,问这个数能否等于一系列连续的质数的和: 解题思路:质数筛打出质数表:然后就是尺取法解决: 代码: #include<iostream> #include<algorithm> #include<cstring> #define maxn 1000005 using namespace std; int visit[maxn];int prime[maxn]; void qprime() { memset(visit,,sizeof(visit)); ;…
题意:选取一系列数,使得这些数的平方和等于n: 解题思路:尺取法扫一遍: #include<iostream> #include<algorithm> using namespace std; struct node { int bin; int len; }a[]; int main() { ,left=,cnt=; ,n; cin>>n; ) { while(sum<n) { sum+=right*right; right++; } if(sum==n) {…
poj3061 给定一个序列找出最短的子序列长度,使得其和大于等于S 那么只要用两个下标,区间和小于S时右端点向右移动,区间和大于S时左端点向右移动,在这个过程中更新Min #include <cstdio> #include <algorithm> #include <cstring> #define MAX 100005 #define LL long long #define INF 0x3f3f3f3f using namespace std; LL a[];…
Jessica's Reading Problem Description Jessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to master all ideas included in a ve…
POJ2739 Sum of Consecutive Prime Numbers 题目大意:给出一个整数,如果有一段连续的素数之和等于该数,即满足要求,求出这种连续的素数的个数 水题:艾氏筛法打表+尺取法区间推进,0ms水过(注意循环的终止条件) #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> #include &l…
Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 23931   Accepted: 13044 Description Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representatio…
第一题太水,跳过了. NanoApe Loves Sequence题目描述:退役狗 NanoApe 滚回去学文化课啦! 在数学课上,NanoApe 心痒痒又玩起了数列.他在纸上随便写了一个长度为 nnn 的数列,他又根据心情随便删了一个数,这样他得到了一个新的数列,然后他计算出了所有相邻两数的差的绝对值的最大值. 他当然知道这个最大值会随着他删了的数改变而改变,所以他想知道假如全部数被删除的概率是相等的话,差的绝对值的最大值的期望是多少. 输入描述 第一行为一个正整数 T,表示数据组数. 每组数…
poj3061 Subsequence 题目链接: http://poj.org/problem?id=3061 挑战P146.题意:给定长度为n的数列整数a0,a1,...,a(n-1)以及整数S,求出总和不小于S的连续子序列的长度的最小值,如果解不存在,则输出零.$10<n<10^5,0<a_i<=10^4,S<10^8$; 思路:尺取法,设起始下标s,截止下标e,和为sum,初始时s=e=0;若sum<S,将sum增加a(e),并将e加1,若sum>=S,更…
[尺取法]Jurisdiction Disenchantment PROBLEM 时间限制: 1 Sec 内存限制: 128 MB 题目描述 The Super League of Paragons and Champions (SLPC) has been monitoring a plot by a corrupt politician to steal an election. In the past week, the politican has used a mind-control…