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. 在VM中给Linux安装Tool

    1.导入tool 2.解压tool 3.打开终端,进入tool的目录,输入  ./XXXXXXX.pl 4.进入安装界面,不断回车即可

  2. Spark结构式流编程指南

    Spark结构式流编程指南 概览 Structured Streaming 是一个可拓展,容错的,基于Spark SQL执行引擎的流处理引擎.使用小量的静态数据模拟流处理.伴随流数据的到来,Spark ...

  3. windows 下编译php扩展库pecl里的扩展memcache

    Memcache是一个高性能的分布式的内存对象缓存系统,通过在内存里维护一个统一的巨大的hash表,它能够用来存储各种格式的数据,包括图像.视频.文件以及数据库检索的结果等.简单的说就是将数据调用到内 ...

  4. supervisor安装配置

    1.安装 下载:https://codeload.github.com/Supervisor/supervisor/zip/3.1.3 2.安装 .zip cd supervisor- python ...

  5. MYSQL性能优化--分库分表

    1.分库分表 1>纵向分表 将本来可以在同一个表的内容,人为划分为多个表.(所谓的本来,是指按照关系型数据库的第三范式要求,是应该在同一个表的.) 分表理由:根据数据的活跃度进行分离,(因为不同 ...

  6. bcache 状态/配置 文件详细介绍

    什么是bcache bcache是linux内核块层cache.它使用类似SSD来作为HDD硬盘的cache,从而起到加速作用. HDD硬盘便宜并且空间更大,SSD速度快但更贵.如果能两者兼得,岂不快 ...

  7. 机器学习:Python中如何使用支持向量机(SVM)算法

    (简单介绍一下支持向量机,详细介绍尤其是算法过程可以查阅其他资) 在机器学习领域,支持向量机SVM(Support Vector Machine)是一个有监督的学习模型,通常用来进行模式识别.分类(异 ...

  8. .Net面试葵花宝典

    1.                面向对象的特征有哪些方面    抽象:抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面.抽象并不打算了解全部问题,而只是选择其中 ...

  9. MySQL存储过程--带参数报错1064

    DELIMITER $$ USE `student`$$ DROP PROCEDURE IF EXISTS `sync_student`$$ CREATE DEFINER=`student`@`%` ...

  10. [笔记]RankSVM 和 IR SVM

    之前的博客:http://www.cnblogs.com/bentuwuying/p/6681943.html中简单介绍了Learning to Rank的基本原理,也讲到了Learning to R ...