King George has recently decided that he would like to have a new design for the royal graveyard. The graveyard must consist of several sections, each of which must be a square of graves. All sections must have different number of graves. 
After a consultation with his astrologer, King George decided that the lengths of section sides must be a sequence of successive positive integer numbers. A section with side length s contains s 2 graves. George has estimated the total number of graves that will be located on the graveyard and now wants to know all possible graveyard designs satisfying the condition. You were asked to find them.

Input

Input file contains n --- the number of graves to be located in the graveyard (1 <= n <= 10 14 ).

Output

On the first line of the output file print k --- the number of possible graveyard designs. Next k lines must contain the descriptions of the graveyards. Each line must start with l --- the number of sections in the corresponding graveyard, followed by l integers --- the lengths of section sides (successive positive integer numbers). Output line's in descending order of l.

Sample Input

2030

Sample Output

2
4 21 22 23 24
3 25 26 27
题意:给你一个数,求连续的整数的平方和为这个整数的个数
题解:尺取
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007 using namespace std; const int N=+,maxn=+,inf=0x3f3f3f3f; ll ss[N],tt[N]; ll solve(ll x)//对x进行尺取
{
ll ans=,s=,t=,sum=;
while((t-)*(t-)<=x){//这里的范围一定要取好,刚开始取t<=x,结果tle了,然后取了t*t<=x,又wa了,因为t*t满足提议的时候会少算一种情况
while(sum<x&&(t-)*(t-)<=x){
sum+=(t*t);
t++;
}
// cout<<sum<<endl;
if(sum<x)break;
if(sum==x)
{
ss[ans]=s;
tt[ans]=t;
ans++;
}
sum-=(s*s);
s++;
}
return ans;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie();
ll n,ans;
cin>>n;
ans=solve(n);
cout<<ans<<endl;
for(int i=;i<ans;i++)
{
cout<<tt[i]-ss[i];
for(int j=ss[i];j<tt[i];j++)
cout<<" "<<j;
cout<<endl;
}
return ;
}

poj2100还是尺取的更多相关文章

  1. Gym 100703I---Endeavor for perfection(尺取)

    题目链接 http://codeforces.com/problemset/gymProblem/100703/I Description standard input/outputStatement ...

  2. NOJ 1072 The longest same color grid(尺取)

    Problem 1072: The longest same color grid Time Limits:  1000 MS   Memory Limits:  65536 KB 64-bit in ...

  3. hdu 4123 Bob’s Race 树的直径+rmq+尺取

    Bob’s Race Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Probl ...

  4. Codeforces Round #116 (Div. 2, ACM-ICPC Rules) E. Cubes (尺取)

    题目链接:http://codeforces.com/problemset/problem/180/E 给你n个数,每个数代表一种颜色,给你1到m的m种颜色.最多可以删k个数,问你最长连续相同颜色的序 ...

  5. poj2566尺取变形

    Signals of most probably extra-terrestrial origin have been received and digitalized by The Aeronaut ...

  6. hdu 6231 -- K-th Number(二分+尺取)

    题目链接 Problem Description Alice are given an array A[1..N] with N numbers. Now Alice want to build an ...

  7. Codeforces 939E Maximize! (三分 || 尺取)

    <题目链接> 题目大意:给定一段序列,每次进行两次操作,输入1 x代表插入x元素(x元素一定大于等于之前的所有元素),或者输入2,表示输出这个序列的任意子集$s$,使得$max(s)-me ...

  8. cf1121d 尺取

    尺取,写起来有点麻烦 枚举左端点,然后找到右端点,,使得区间[l,r]里各种颜色花朵的数量满足b数组中各种花朵的数量,然后再judge区间[l,r]截取出后能否可以供剩下的n-1个人做花环 /* 给定 ...

  9. HDU 5178 pairs【二分】||【尺取】

    <题目链接> 题目大意: 给定一个整数序列,求出绝对值小于等于k的有序对个数. 解题分析: $O(nlong(n))$的二分很好写,这里就不解释了.本题尺取$O(n)$也能做,并且效率很不 ...

随机推荐

  1. Selenium2 WebDriver环境搭建

    1.下载Selenium Client Servers包 在Selenium官网上可以下载到最新的开源的包http://seleniumhq.org/download/,根据编写测试脚本所使用的语言下 ...

  2. Linux学习之Vim使用

    一 为何要学Vim 所有的Unix Like系统都有自带vi编辑器 一些软件的编辑接口会自动调起vi 作为vi的升级版,vim具有程序编辑功能,而且具有代码颜色高亮显示.辨别代码的正确性等功能 以上优 ...

  3. Mysql的2003错误 cant connect to mysql 10060的解决

    网上有很多这个问题,令人遗憾的是,都是复制粘贴的繁琐的命令行操作.我解决这个问题是在安装有可视化工具的前提下完成的.我想,使用Mysql数据库的大多数还是安装有可视化开发工具的吧,我就用phpMyAd ...

  4. iOS开发优秀博客和软件推荐

    iOSBlogAndTools iOS开发优秀博客和软件推荐 本博客和工具列表由广大iOS开发者收集和推荐,如果大家有好的博客或者工具想要分享请点击:我要提交. 收到大家的提交后会及时收录与更新.Gi ...

  5. 利用firefox调试安卓手机端web

    分2部分: 手机: 1.安装最新版firefox 2.打开浏览器,输入about:config 3.设置 devtools.debugger.remote-enabled 值为true devtool ...

  6. Unity 3D Framework Designing(3)——构建View和ViewModel的生命周期

    > 对于一个View而言,本质上是一个MonoBehaviour.它本身就具备生命周期这个概念,比如,Awake,Start,Update,OnDestory等.这些是非常好的方法,可以让开发者 ...

  7. 2.4G无线收发模块/射频RFM75调试总结/RF知识整理

    射频RFM75通信是收发双方都需要编程的器件,收发双方的通道频率,空中传输速率设置一致,调试时必须先调通一块再调另一块,否则出现问题了就不知道是发送端有问题还是接收端有问题.调试必须理清思路.正确的方 ...

  8. iOS回顾笔记(09) -- Cell的添加、删除、更新、批量操作

    iOS回顾笔记(09) -- Cell的添加.删除.更新.批量操作 项目中经常有对UITableViewCell做各种操作的需求: 添加一个新的cell 删除某行cell 刷新cell上某行数据(如修 ...

  9. vuejs单一事件管理组件间的通信

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. CentOS 7 Root用户密码重置 2017-04-02

    跨平台系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#linux 开机的时候按e (如果正在使用,你可以输入reboot,然后赶紧按回车键,也可 ...