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. 使用Akka的远程调用

    概述 正如其它RPC或者RMI框架那样,Akka也提供了远程调用的能力.服务端在监听的端口上接收客户端的调用.本文将在<Spring与Akka的集成>一文的基础上介绍Akka的remote ...

  2. 深度揭秘腾讯云新一代企业级HTAP数据库TBase核心概念

    腾讯云PostgreSQL-XZ(PGXZ)经过公司内部多年业务的打磨,在2017年改名为TBase后,正式对外推出,目前已在政务.医疗.公安.消防.电信.金融等行业等行业的解决方案中大量应用.TBa ...

  3. 为什么VUE注册组件命名时不能用大写的?

    这段时间一直在弄vue,当然也遇到很多问题,这里就来跟大家分享一些注册自定义模板组件的心得 首先"VUE注册组件命名时不能用大写"其实这句话是不对的,但我们很多人开始都觉得是对的, ...

  4. 从零单排学Redis【黄金】

    前言 只有光头才能变强 好的,今天我们要上黄金段位了,如果还没经历过青铜和白银阶段的,可以先去蹭蹭经验再回来: 从零单排学Redis[青铜] 从零单排学Redis[白银] 看过相关Redis基础的同学 ...

  5. SignalR 中丰富多彩的消息推送方式

    在上一篇 SignalR 文章中,演示了如何通过 SignalR 实现了简单的聊天室功能:本着简洁就是美的原则,这一篇我们也来聊聊在 SignalR 中的用户和组的概念,理解这些基础知识有助于更好的开 ...

  6. 第四节 pandas 数据加载

    pandas提供了一些用于将表格型数据读取为DataFrame对象的函数,其中read_csv和read_table这两个使用最多. #导包import pandas as pd from panda ...

  7. vue项目中vux的使用

    vux VUX 是基于 WeUI 和 Vue.js 的 移动端 UI 组件库,提供丰富的组件满足移动端(微信)页面常用业务需求. 在vue-cli中使用步骤如下: 1.安装: npm i vux -S ...

  8. Dynamics CRM模拟OAuth请求获得Token后在外部调用Web API

    关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复233或者20161104可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong. ...

  9. QQ登录界面布局

    简单的qq登录界面布局 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmln ...

  10. PHP全栈学习笔记2

    php概述 什么是php,PHP语言的优势,PHP5的新特性,PHP的发展趋势,PHP的应用领域. PHP是超文本预处理器,是一种服务器端,跨平台,HTML嵌入式的脚本语言,具有c语言,Java语言, ...