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,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,};
void dabiao(){ for(int i=;i<=;i++){
if(flag[i])continue;
prime[cnt++]=i;
for(int j=;j*i<=;j++)
flag[i*j]=;
}
} int main(){
dabiao();
while(scanf("%d",&n),n){
int l=,r=,sum=,ans=;
while(){
if(sum==n) ans++;
if(sum>=n) sum-=prime[l++];
else{
if(prime[r]<=n) sum+=prime[r++];
else break;
}
}
printf("%d\n",ans);
}
}

poj2100单点推移

#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#define ll long long using namespace std; vector<ll> vec[];
ll cnt,n; int main(){
while(scanf("%lld",&n)==){
ll l=,r=,sum=;
for(int i=;i<=cnt;i++)
vec[i].clear();
cnt=;
while(){ if(sum==n){
cnt++;
for(int i=l+;i<=r;i++)
vec[cnt].push_back(i);
}
if(sum>=n){
l++;
sum-=l*l;
}
else {
if(r*r<=*n){
r++;
sum+=r*r;
}
else break;
}
}
printf("%lld\n",cnt);
for(int i=;i<=cnt;i++){
printf("%d ",vec[i].size());
for(int j=;j<vec[i].size();j++)
printf("%lld ",vec[i][j]);
puts("");
}
}
return ;
}

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

  1. poj2739(尺取法+质数筛)

    题意:给你一个数,问这个数能否等于一系列连续的质数的和: 解题思路:质数筛打出质数表:然后就是尺取法解决: 代码: #include<iostream> #include<algor ...

  2. poj2100(尺取法)

    题意:选取一系列数,使得这些数的平方和等于n: 解题思路:尺取法扫一遍: #include<iostream> #include<algorithm> using namesp ...

  3. poj3061 poj3320 poj2566尺取法基础(一)

    poj3061 给定一个序列找出最短的子序列长度,使得其和大于等于S 那么只要用两个下标,区间和小于S时右端点向右移动,区间和大于S时左端点向右移动,在这个过程中更新Min #include < ...

  4. POJ 3320 尺取法(基础题)

    Jessica's Reading Problem Description Jessica's a very lovely girl wooed by lots of boys. Recently s ...

  5. POJ2739 Sum of Consecutive Prime Numbers(尺取法)

    POJ2739 Sum of Consecutive Prime Numbers 题目大意:给出一个整数,如果有一段连续的素数之和等于该数,即满足要求,求出这种连续的素数的个数 水题:艾氏筛法打表+尺 ...

  6. POJ2739(尺取法)

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 23931 ...

  7. BestCoder Round #86 二,三题题解(尺取法)

    第一题太水,跳过了. NanoApe Loves Sequence题目描述:退役狗 NanoApe 滚回去学文化课啦! 在数学课上,NanoApe 心痒痒又玩起了数列.他在纸上随便写了一个长度为 nn ...

  8. POJ 尺取法

    poj3061 Subsequence 题目链接: http://poj.org/problem?id=3061 挑战P146.题意:给定长度为n的数列整数a0,a1,...,a(n-1)以及整数S, ...

  9. 【尺取法】Jurisdiction Disenchantment

    [尺取法]Jurisdiction Disenchantment PROBLEM 时间限制: 1 Sec 内存限制: 128 MB 题目描述 The Super League of Paragons ...

随机推荐

  1. 移动端自动化测试-Windows-Android-Appium环境搭建

    1.安装JDK,并且配置好[JAVA_HOME]和[path]两个环境变量 1.1.JAVA_HOME:指向JDK的安装路径(如:C:\Program Files (x86)\Java\jdk1.7. ...

  2. Harbor之Swagger REST API

    目录 Swagger介绍 Harbor Swagger预览 整合本地Harbor与Swagger Swagger介绍 Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTFu ...

  3. 在windows环境下实现开机延迟启动tomcat

    如果说我们的服务器断电了 开机之后还需要手动开下服务  还需要远程连接上  然后一个一个开启  是不是很麻烦  我们可以写一个bat脚本  然后设置开机5分钟之后启动tomcat 首先配置环境变量: ...

  4. 加减乘除工具类BigDecimalUtil

    场景:为毛要用BigDecimal这个类来实现加减乘除呢?我不说其他的,你去用小数乘小数,除小数就知道.话不多说,老规矩,开箱即用. BigDecimalUtil.java package com.m ...

  5. SQL记录-资源正忙online或nowait

    1.多个tomcat 修改3个端口 2.oracle-00054:资源正忙 被锁住了 建立索引加online参数 1:创建索引时会产生的锁 2:dml 语句会产生的锁 3:索引创建时加上关键字 onl ...

  6. POJ 2247 Humble Numbers

    A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, ...

  7. This page is about building Firefox Desktop

    This page is about building Firefox Desktop The Mozilla build system, like the rest of the Mozilla c ...

  8. Nginx 虚拟主机示例

    Nginx server 模块 server { // 标识虚拟主机开始 listen ; ## // 指定虚拟主机服务器端口 server_name localhost; // 指定 IP地址或者域 ...

  9. python的安装和pycharm的安装

    下载地址   官网:https://www.python.org/downloads/release/python-372/ Window 平台安装 Python: Add python xx to ...

  10. [转]python 装饰器

    以前你有没有这样一段经历:很久之前你写过一个函数,现在你突然有了个想法就是你想看看,以前那个函数在你数据集上的运行时间是多少,这时候你可以修改之前代码为它加上计时的功能,但是这样的话是不是还要大体读读 ...