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. SqlServer转换为Mysql

    昨天顺利把MySQL成功安装后,正准备着手把原来项目中的SQL SERVER数据库改为MYSQL数据库,可大量的表结构和表数据如要手动写,那就...... 接下来就是各种百度.谷歌.问先驱等,可得到的 ...

  2. Seajs使用实例入门介绍

    本文所用例子的代码目录结构: seajs example |--sea-module //存在依赖文件 |--jquery |--jqeury.js |--sea.js |--static //存放自 ...

  3. Windows上安装Kafka需要注意的几点

    1.不能安装在有空格的路径上 比如:D:\Program Files 2.设置日志路径时,要用"/",不能用Windows上的"\",比如: # A comma ...

  4. js的几种简单排序算法及其效率实测

    function swap(arr,index1,index2){ var t = arr[index1]; arr[index1] = arr[index2]; arr[index2] = t; } ...

  5. JDK中日期和时间的几个常用类浅析(五)

    LocalDateTime   LocalDateTime是JDK8中才引入的类,用来表示不包含时区信息的本地日期和时间.我们可以把LocalDateTime看作是LocalDate和LocalTim ...

  6. 从面试小白走向master

    腾讯2017春招(实习生招聘)在线笔试知识点总结: 1.栈与队列(用队列实现栈) 2.排序算法(最坏情况下时间复杂度) 3.TCP协议(3次

  7. 通过Elasticsearch使用的你的数据

    Elasticsearch 系列导航 elasticsearch 与 elasticsearch-head 的安装 ElasticSearch Index API && Mapping ...

  8. Android ShellUtils

    Android中执行Shell命令的工具类 public class ShellUtils { public static final String COMMAND_SU = "su&quo ...

  9. JavaScript学习总结 之对象

    JavaScript学习总结(二) ---- 对象 在JavaScript中,几乎用到的每个js都离不开它的对象.下面我们深入了解一下js对象. js中对象的分类跟之前我们学过的语言中函数的分类一样, ...

  10. ArrayList,LinkedList的对比

    ArrayList,LinkedList都是Collection接口的通用实现方式,两者采用了不用的存储策略,用来适应不同场合的需要. 实现方式 ArrayList的内部采用集合的方式存储数据 唯一需 ...