Perfect Cubes
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 16522   Accepted: 8444

Description

For hundreds of years Fermat's Last Theorem, which stated simply that for n > 2 there exist no integers a, b, c > 1 such that a^n = b^n + c^n, has remained elusively unproven. (A recent proof is believed to be correct, though it is still undergoing scrutiny.) It is possible, however, to find integers greater than 1 that satisfy the "perfect cube" equation a^3 = b^3 + c^3 + d^3 (e.g. a quick calculation will show that the equation 12^3 = 6^3 + 8^3 + 10^3 is indeed true). This problem requires that you write a program to find all sets of numbers {a,b,c,d} which satisfy this equation for a <= N.

Input

One integer N (N <= 100).

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.

描述

数百年来费马的最后定理,其简单地说明,对于n> 2,没有整数a,b,c> 1使得a ^ n = b ^ n + c ^ n仍然难以确认。(最近的证据被认为是正确的,尽管它仍在进行详细审查。)然而,有可能找到满足“完美立方”方程的大于1的整数a ^ 3 = b ^ 3 + c ^ 3 + d ^ 3(例如,快速计算将显示等式12 ^ 3 = 6 ^ 3 + 8 ^ 3 + 10 ^ 3确实为真)。这个问题要求你编写一个程序来查找满足<= N的这个等式的所有数字{a,b,c,d}。

输入

一个整数N(N <= 100)。

产量

输出应如下所示列出,每行一个完美的立方体,以a的非递减顺序排列(即行应按其值排序)。b,c和d的值也应该在线本身上以非递减顺序列出。确实存在几个可以从多个不同的b,c和d三元组产生的a值。在这些情况下,应首先列出b值较小的三元组。

Sample Input

24

Sample Output

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)

Source

 
#include <stdio.h>
int main(){
    int n,a,b,c,d;
    scanf("%d",&n);
    for(a=2;a<=n;++a)
        for(b=2;b<a;++b)
            for(c=b;c<a;++c)
                for(d=c;d<a;++d)
                    if(a*a*a==b*b*b+c*c*c+d*d*d)
                        printf("Cube = %d, Triple = (%d,%d,%d)\n",a,b,c,d);
    return 0;
}

  

Poj1543的更多相关文章

  1. OJ题目分类

    POJ题目分类 | POJ题目分类 | HDU题目分类 | ZOJ题目分类 | SOJ题目分类 | HOJ题目分类 | FOJ题目分类 | 模拟题: POJ1006 POJ1008 POJ1013 P ...

随机推荐

  1. GC参考手册 —— GC 调优(命令篇)

    运用jvm自带的命令可以方便的在生产监控和打印堆栈的日志信息帮忙我们来定位问题!虽然jvm调优成熟的工具已经有很多:jconsole.大名鼎鼎的VisualVM,IBM的Memory Analyzer ...

  2. 微信小程序之表单验证

    表单验证 何为表单验证呢? 百度百科给出的回答是这样的: 表单验证是javascript中的高级选项之一.JavaScript 可用来在数据被送往服务器前对 HTML 表单中的这些输入数据进行验证 [ ...

  3. 如何手写JDK锁

    手写JDK锁 需要三个步骤: 手写一个类MyLock,实现Lock接口 重写lock()方法 重写unlock()方法 代码: public class MyLock implements Lock ...

  4. 详解mybatis映射配置文件

    一  mybatis 映射文件结构 mybatis映射配置文件存在如下顶级元素,且这些元素按照如下顺序被定义. cache – 给定命名空间的缓存配置. cache-ref – 其他命名空间缓存配置的 ...

  5. SoEasyPlatform 代码生成器

    介绍 一款轻量级开源的代码生成器,相对较动软代码生成器而言要轻量的多,支持多种数据库,所用到dll组件也都在github有源码,代码非常的简单有点基础的看源码可以把生成的项目改成自已的风格. 特色 该 ...

  6. CSS 火焰?不在话下

    正文从下面开始. 今天的小技巧是使用纯 CSS 生成火焰,逼真一点的火焰. 嗯,长什么样子?在 CodePen 上输入关键字 CSS Fire,能找到这样的: 或者这样的: 我们希望,仅仅使用 CSS ...

  7. ArcGIS JS Api 4.x修改三维球背景技巧

        通过修改scenceview.js中tileBackground和defaultTileBackground中的png的base64编码就可以达到要求. 4.8中通过修改scenceview. ...

  8. SqlServer_查看SQLServer版本信息

    方法一: 执行sql语句 SELECT @@VERSION 方法二: 连接SQL Server Management Studio利用Object Explorer显示的主要版本号信息,显示当前实例产 ...

  9. SQL SERVER 查看所有存储过程或视图里 包含某个关键字的查询语句

    SELECT name, type_desc FROM sys.all_sql_modules s INNER JOIN sys.all_objects o ON s.object_id = o.ob ...

  10. 访问System x3650 IMM2的几种方式

    一.通过web浏览器访问 1.打开浏览器,在地址栏上输入IMM2的IP地址访问,打开登录页面后,输入用户名和密码 登录 PS:第一次登录IMM2时,初始的用户名为USERID,密码为PASSW0RD( ...