HOJ 2201 Sum of Cubes
来源:互联网 发布:苹果同步铃声软件 编辑:程序博客网 时间:2024/05/17 05:07
Time limit : 10 sec Memory limit : 64 M
注意:x和y并没有指明是正数
According to Goldbach’s conjecture, every evennumber can be expressed as a sum of two oddprimes. Which numbers can be expressed as thesum of two cubes?
For each test case, a line will contain a positive integer n which will be at most one million.For each test case, output two integers x and y such that x3 + y3 = n. If there are manysuch pairs of numbers, choose x to be as small as possible. If there are no such pairs, output“impossible”.
The last line will contain the integer 0, which should not be processed.
Sample Input
12310000000
Sample Output
0 11 1impossible0 100
Solution:
#include <stdio.h>#include <math.h>int main(){ int x, y, n; while(1 == scanf("%d", &n)) { if(0 == n) return 0; x = -600; y = 600; for(;x <= y;) { if ((int)(pow(x, 3) + pow(y, 3)) > n) { --y; } else if ((int)(pow(x, 3) + pow(y, 3)) < n) { ++x; } else { printf("%d %d\n", x, y); break; } } if (x > y) { printf("impossible\n"); } } return 0;}
注意:x和y并没有指明是正数
- HOJ 2201 Sum of Cubes
- HOJ 2201 Sum of Cubes
- HOJ 1302 Sum of Factorials
- HOJ The Colored Cubes
- hdu 3113 Sum of Cubes 数学 枚举 剪枝
- Hoj 2084 The Colored Cubes (polya计数)
- 10051 - Tower of Cubes----------
- 10051 - Tower of Cubes
- UVA10051 Tower of Cubes
- UVA10051- - Tower of Cubes
- lightoj1211 Intersection of Cubes
- Tower of Cubes UVA
- uva 10051 Tower of Cubes
- UVa 10051. Tower of Cubes
- uva_10051 - Tower of Cubes(LIS)
- LightOJ 1211 Intersection of Cubes
- UVA 10051 Tower of Cubes
- uva 10051 Tower of Cubes
- ios开发之ASIHTTPRequest-使用download cache
- 向ios进发
- tslib-1.4的安装与移植
- 帮助文档.chm能打开但是显示不出来详细内容
- STL+auto_ptr智能指针简单分析
- HOJ 2201 Sum of Cubes
- MySQL优化(InnoDB)
- 一个Onlybird的小Bash脚本,不解释
- 快捷键
- C语言反汇编入门实例
- 程序员改bug
- CentOS 安装配置Samba
- ios开发之设置表格单元格交替背景
- 多重继承中函数同名