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. Node.js + MySQL 实现数据的增删改查

    通过完成一个 todo 应用展示 Node.js + MySQL 增删改查的功能.这里后台使用 Koa 及其相应的一些中间件作为 server 提供服务. 初始化项目 $ mkdir node-cru ...

  2. 线上应用调试利器 --Arthas

    在之前的文章中,我介绍了使用 Btrace 工具进行线上代码的debug (https://www.cnblogs.com/yougewe/p/10180483.html),其大致原理就是通过字节码注 ...

  3. js-刮刮卡效果,由jquery-eraser源码改的vue组件

    vue-eraser 一款用于vue刮刮卡的组件 github地址: vue-eraser npm地址: vue-eraser 在网上有看到过几个版本的组件,都有点问题 1.拉快了,就会断,连不起来( ...

  4. Java_基础篇(数组的反转)

    数组反转也是Java的基础. 数组反转要求掌握的是: 1).创建一个数组,在内存中申请一块空间. 2).实例化数组. 3).对数组的了解.如:数组的长度,数组的下标,数组的表示方法. 4).数组的交换 ...

  5. Django学习之十二:Cache 缓存组件

    目录 Django Cache 缓存组件 缓存逻辑伪代码 配置缓存源 可配置参数说明 01. Django的默认缓存 02. 基于Redis的django-redis 03. 自定义cache 04. ...

  6. vtigercrm特色功能介绍

    1.邮件跟踪 市场营销活动中,我们给客户发出了大量的电子邮件,这些邮件被客户阅读的情况你了解吗?vtiger CRM中独特的邮件跟踪功能,可以让你了解到邮件是否被客户浏览.浏览的次数和时间.通过客户的 ...

  7. weblogic816 bug list

    weblogic816在aix下的补丁汇总: 严重 Patch 8173326,weblogic server挂起,threaddump显示SERVER HANGS TRYING TO CALL LO ...

  8. Redis Sentinel集群双机房容灾实施步骤

    概要目标防止双机房情况下任一个机房完全无法提供服务时如何让Redis继续提供服务.架构设计A.B两机房,其中A机房有一Master一Slave和两个Sentinel,B机房只有2个Sentinel,如 ...

  9. windows 结束端口占用

    1. cmd 调出命令行窗口 2. netstat -ano  查看端口被占用情况 3.命令:tasklist | findstr "9480"  发现被httpd.exe 占用 ...

  10. [原创] 分享我们自己搭建的微信小程序开发框架——wframe及设计思想详解

    wframe不是控件库,也不是UI库,她是一个微信小程序面向对象编程框架,代码只有几百行.她的主要功能是规范小程序项目的文件结构.规范应用程序初始化.规范页面加载及授权管理的框架,当然,wframe也 ...