zoj1331----------------Perfect Cubes
来源:互联网 发布:pl sql develop 编辑:程序博客网 时间:2024/05/16 14:56
Output
The output should be listed as shown below, one perfect cube per line, in non-decreasing order of a (i.e. the lines should be sorted by their a values). The values of b, c, and d should also be listed in non-decreasing order on the line itself. There do exist several values of a which can be produced from multiple distinct sets of b, c, and d triples. In these cases, the triples with the smaller b values should be listed first.
The first part of the output is shown here:
Cube = 6, Triple = (3,4,5)
Cube = 12, Triple = (6,8,10)
Cube = 18, Triple = (2,12,16)
Cube = 18, Triple = (9,12,15)
Cube = 19, Triple = (3,10,18)
Cube = 20, Triple = (7,14,17)
Cube = 24, Triple = (12,16,20)
Note: The programmer will need to be concerned with an efficient implementation. The official time limit for this problem is 2 minutes, and it is indeed possible to write a solution to this problem which executes in under 2 minutes on a 33 MHz 80386 machine. Due to the distributed nature of the contest in this region, judges have been instructed to make the official time limit at their site the greater of 2 minutes or twice the time taken by the judge's solution on the machine being used to judge this problem.
#include <iostream>using namespace std;int main(){int a,b,c,d;for(a=6;a<=200;a++)for(b=2;b<=200;b++)for(c=b;c<=200;c++)for(d=c;d<=200;d++)if(a*a*a==b*b*b+c*c*c+d*d*d)cout<<"Cube = "<<a<<", Triple = ("<<b<<","<<c<<","<<d<<")"<<endl;return 0;}
- zoj1331----------------Perfect Cubes
- Perfect Cubes
- Perfect Cubes
- Perfect Cubes
- zoj 1331 Perfect Cubes
- poj 1543Perfect Cubes
- zoj 1331 Perfect Cubes
- poj 1543 Perfect Cubes
- ZOJ 1331 Perfect Cubes
- zoj 1331 Perfect Cubes
- ZOJ 1331 Perfect Cubes
- POJ 1543 Perfect Cubes
- HDU1334:Perfect Cubes
- poj_1543 Perfect Cubes
- hdu1334-Perfect Cubes
- [catch]--Perfect Cubes
- POJ 1543 - Perfect Cubes
- ZOJ 1331 - Perfect Cubes
- linux中的环境变量
- MFC全屏
- MongoDB CRUD操作简析
- TCP建立连接时的三次握手和断开连接时的四次握手
- alter system switch logfile和alter system archive log current的区别
- zoj1331----------------Perfect Cubes
- HTTP深入浅出 http请求
- 区域例子浅析
- MFC中创建没有子窗口的MDI应用程序
- ubuntu server端,如何访问U盘
- Unix编程之size_t、ssize_t
- C#并行开发_Thread/ThreadPool, Task/TaskFactory, Parallel
- 进程相关的API
- miss bootmgr的问题