Description

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 s2graves. 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 ( <= n <=  ).

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


Sample Output


Source

Northeastern Europe 2004, Northern Subregion
 
尺取法,具体看代码
 
 #include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long
vector< pair<ll,ll> >ans; int main()
{
ll n;
while(scanf("%I64d",&n)==){
ll s=,t=;
ll sum=;
for(;;){ while(sum<n){
sum=sum+t*t;
t++;
}
if((t-)*(t-)>n)
break;
if(sum==n){
ans.push_back(make_pair(s,t-));
}
sum-=s*s;
s++; }
ll m=ans.size();
printf("%I64d\n",m);
for(int i=;i<m;i++){
ll l=ans[i].first;
ll r=ans[i].second;
printf("%I64d",r-l+);
for(ll j=l;j<=r;j++){
printf(" %I64d",j);
}
printf("\n"); }
}
return ;
}

poj 2100 Graveyard Design(尺取法)的更多相关文章

  1. poj 2100 Graveyard Design

    直接枚举就行了 #include<iostream> #include<stdio.h> #include<algorithm> #include<ioman ...

  2. poj 2566"Bound Found"(尺取法)

    传送门 参考资料: [1]:http://www.voidcn.com/article/p-huucvank-dv.html 题意: 题意就是找一个连续的子区间,使它的和的绝对值最接近target. ...

  3. poj 3061(二分 or 尺取法)

    传送门:Problem 3061 https://www.cnblogs.com/violet-acmer/p/9793209.html 马上就要去上课了,先献上二分AC代码,其余的有空再补 题意: ...

  4. POJ 2566 Bound Found(尺取法,前缀和)

    Bound Found Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 5207   Accepted: 1667   Spe ...

  5. POJ 3061 Subsequence ( 尺取法)

    题目链接 Description A sequence of N positive integers (10 < N < 100 000), each of them less than ...

  6. poj 3320 复习一下尺取法

    尺取法(two point)的思想不难,简单来说就是以下三步: 1.对r point在满足题意的情况下不断向右延伸 2.对l point前移一步 3.  回到1 two point 对连续区间的问题求 ...

  7. poj 2566 Bound Found 尺取法 变形

    Bound Found Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 2277   Accepted: 703   Spec ...

  8. POJ 3061 Subsequence ( 二分 || 尺取法 )

    题意 : 找出给定序列长度最小的子序列,子序列的和要求满足大于或者等于 S,如果存在则输出最小长度.否则输出 0(序列的元素都是大于 0 小于10000) 分析 : 有关子序列和的问题,都可以考虑采用 ...

  9. poj 2566 Bound Found 尺取法

    一.首先介绍一下什么叫尺取 过程大致分为四步: 1.初始化左右端点,即先找到一个满足条件的序列. 2.在满足条件的基础上不断扩大右端点. 3.如果第二步无法满足条件则到第四步,否则更新结果. 4.扩大 ...

随机推荐

  1. Java体系总结

    一.Java SE部分 1.java基础:基础语法:面向对象(重点):集合框架(重点):常见类库API: 2.java界面编程:AWT:事件机制:Swing: 3.java高级知识:Annotatio ...

  2. linux下mysql的卸载、安装全过程

    卸载mysql 1.查找以前是否装有mysql 命令:rpm -qa|grep -i mysql 可以看到mysql的两个包: mysql-4.1.12-3.RHEL4.1 mysqlclient10 ...

  3. 邮件协议(SMTP)性能测试总结(Foxmail邮箱)

    先介绍一下邮件协议SMTP的工作机制(连接和发送过程),用wireshark工具抓包进行分析,如下: SMTP协议的工作机制(连接和发送过程): 1.建立TCP连接,并将邮件服务器地址给客户端: 2. ...

  4. redis安装过程中遇到的问题

    正常的 wget http://download.redis.io/releases/redis-3.0.7.tar.gz下载 解压缩 tar -zxvf redis-3.0.7.tar.gz cd ...

  5. linux内存机制

    ~# free -m         total used  free shared buffers cachedMem: 16086 8579 7507    0      152      800 ...

  6. 前端 JavaScript基础

    前言 JavaScript 是属于网络的脚本语言,被数百万计的网页用来改进设计.验证表单.检测浏览器.创建cookies,以及更多的应用. 一.如何编写 1.存在形式 方式一:存在js文件中,即写入j ...

  7. 任务栈 启动模式 Flag taskAffinity

    关于任务栈Task 栈的概念 栈(Stack)是一种常用的数据结构,栈只允许访问栈顶的元素,栈就像一个杯子,每次都只能取杯子顶上的东西,而对于栈就只能每次访问它的栈顶元素,从而可以达到保护栈顶元素以下 ...

  8. (七)《Java编程思想》——多态的缺陷

    1.不能“覆盖”私有方法 package chapter8; /** * 不能"覆盖"私有方法 */ public class PrivateOverride { private ...

  9. C#Graphics画图

    public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { G ...

  10. C#自定义Attribute值的获取与优化

    C#自定义Attribute值的获取是开发中会经常用到的,一般我们的做法也就是用反射进行获取的,代码也不是很复杂. 1.首先有如下自定义的Attribute [AttributeUsage(Attri ...