墓地

  题目大意,给定一个整数,要你找出他的平方和组合

  太简单了。。。。不过一开始我储存平方和想降低时间,后来发现会超内存,直接用时间换空间了,游标卡尺法

  

 #include <iostream>
#include <functional>
#include <algorithm>
#define MAX_N 10000001 using namespace std;
typedef long long LL_INT; static int store[MAX_N][];//只储存开始和结尾 void Inivilize(void); int main(void)
{
LL_INT n, sum, tmp;
int s, t, num; while (~scanf("%lld", &n))
{
sum = num = ; s = t = ;
while ()
{
while ((tmp = (LL_INT)t*(LL_INT)t) <= n && sum < n)
{
sum += tmp;
t++;
}
if (sum == n)
{
store[num][] = s; store[num][] = t;
num++;
}
if (sum < n)
break;
sum -= (LL_INT)s*(LL_INT)s; s++;
}
printf("%d\n", num);
for (int i = ; i < num; i++)
{
printf("%d ", store[i][] - store[i][]);
for (int j = store[i][]; j < store[i][]; j++)
printf("%d ", j);
printf("\n");
}
}
return EXIT_SUCCESS;
}

  

最新文章

  1. uva 11059 maximum product(水题)——yhx
  2. /bin/dd if=/path/to/source-file of=/path/to/backup-file
  3. 关于Switch结构利用
  4. API基础开发学习网址
  5. 训练趣题:黑与白 有A、B、C、D、E五人,每人额头上都帖了一张黑或白的纸。(此处用javascript实现)
  6. DEDECMS 关键字不能小于2个字节!
  7. 武汉科技大学ACM :1005: A+B for Input-Output Practice (V)
  8. java写文件时,输出不完整的原因以及解决方法
  9. 如何使用GOOLE
  10. AT24C02使用详解
  11. tensorflow第一篇---numpy模块
  12. python 操作RabbitMq详解
  13. css 多行文本的溢出显示省略号(移动端)
  14. TCP/IP 笔记 - 防火墙和网络地址转换
  15. 讲一讲MySQL如何防止“老鼠屎”类型的SQL语句
  16. Oracle时间的加减
  17. SQLSERVER 子查询中使用ORDER BY
  18. linux .zip 解压命令集
  19. pythonNET day05
  20. FusionCharts制作实时刷新图

热门文章

  1. php 选择排序法
  2. CF460D Little Victor and Set (找规律)
  3. C#中的抽象方法和虚方法有什么区别?
  4. Android Studio升级后,开启时遇到tools.jar seems to be not in Android Studio错误?
  5. mac 下 xampp 多域名 多站点 多虚拟主机 配置
  6. ajax提交Form
  7. 【转】CentOS环境下yum安装LAMP(Linux+Apache+Mysql+php)
  8. HDU 4803 Poor Warehouse Keeper
  9. CSS继承总结
  10. ios 异常捕获