poj 2100 尺取法
来源:互联网 发布:淘宝无线端链接生成 编辑:程序博客网 时间:2024/04/29 12:15
大大的疑问。为什么数据换成 int 就会超时呢?而变成long long就ac....求大神指教。
下附 尺取法的代码:
#include <cstdio>#include <iostream>using namespace std;pair<long long,long long>p[1000000];int main(){long long k,sum=0;while(~scanf("%I64d",&k)){sum=0;long long a=1,b=1,ans=0;while(1){while(sum<k){sum+=b*b;b++;}if(sum==k)p[ans++]=make_pair(a,b);if((b-1)*(b-1)>k) //一开始用b*b>k wa了几次。break;sum-=a*a;a++;}printf("%lld\n",ans);for(int i=0;i<ans;i++){printf("%lld ",p[i].second-p[i].first);for(long long j=p[i].first;j<p[i].second;j++)printf("%lld ",j);printf("\n");}}return 0;}
0 0
- poj 2100 尺取法
- POJ 2100 - Graveyard Design(尺取法)
- poj 2100 尺取法连续平方和
- POJ - 2100 Graveyard Design(尺取法)
- POJ-2100Graveyard Design(尺取法)
- POJ 2100 Graveyard Design(尺取法)
- poj 2100 Graveyard Design(尺取法)
- POJ 2100 Graveyard Design 尺取法
- POJ - 2100 Graveyard Design(尺取法)
- POJ 2100 Graveyard Design(尺取法)
- POJ 2100 · Graveyard Design【尺取法】
- POJ 2566 尺取法
- POJ 2566 尺取法
- poj 3061 尺取法
- poj 3061 尺取法
- poj 2566 尺取法
- poj 3061 尺取法
- poj 3320 尺取法
- 较老版本 AFNetworking 使用心得
- Linux 一句话命令
- 关于博主
- 第六周作业1——利用哈夫曼编码英文字母表
- 线程pthread_create,pthread_join
- poj 2100 尺取法
- 实现输出h264直播流的rtmp服务器 flash直播服务器
- 最小堆 / 优先队列(C语言实现)
- 10gocm->session1->数据库和网络配置
- HIT_Training_20140415
- myeclipse db brower 链接 sql server 2008 时
- VS2012的插件,可以编辑lua,高亮,自动完成等。BabeLua is a free lua editor/debuger (vs extension)
- 序列号
- Java正则表达式例子汇总