http://acm.hdu.edu.cn/showproblem.php?pid=1334

题意;求200以内所有满足a^ 3 == b^ 3 + c ^ 3 +d ^ 3

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<iomanip> using namespace std; int main()
{
int a , b , c , d ;
for( int a = 2 ; a <= 200 ; ++a )
for( int b = 2 ; b <= a; ++ b )
for( int c = b + 1 ; c <= a ; ++c )
for( int d = c + 1 ; 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 ;
}
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<iomanip> using namespace std; int main()
{
int a , b , c , d ;
int num[ 201 ] ;
for( int i = 1 ; i <= 200 ; ++i )
{
num[ i ] = i * i * i ;
}
for( a = 6 ; a <= 200 ; ++a )
{
for( b = 2 ; b <= a ; ++b )
{
int x = num[ a ] - num[ b ] ;
for( c = b + 1 ; c <= a ; ++c)
{
int y = x - num[ c ];
for( d = c + 1 ; d <= a ; ++d )
{ if( num[ d ] == y )
printf( "Cube = %d, Triple = (%d,%d,%d)\n" , a , b , c , d ) ;
}
}
}
}
return 0 ;
}

hdu1334-Perfect Cubes的更多相关文章

  1. poj 1543 Perfect Cubes(注意剪枝)

    Perfect Cubes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14901   Accepted: 7804 De ...

  2. OpenJudge 2810(1543) 完美立方 / Poj 1543 Perfect Cubes

    1.链接地址: http://bailian.openjudge.cn/practice/2810/ http://bailian.openjudge.cn/practice/1543/ http:/ ...

  3. POJ 1543 Perfect Cubes

    Perfect Cubes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12595   Accepted: 6707 De ...

  4. poj 1543 Perfect Cubes (暴搜)

    Perfect Cubes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 15302   Accepted: 7936 De ...

  5. HDOJ 1334 Perfect Cubes(暴力)

    Problem Description For hundreds of years Fermat's Last Theorem, which stated simply that for n > ...

  6. ZOJ Problem Set - 1331 Perfect Cubes 判断一个double是否为整数

    zju对时间要求比较高,这就要求我们不能简单地暴力求解(三个循环搞定),就要换个思路:因为在循环时,已知a,确定b,c,d,在外重两层循环中已经给定了b和c,我们就不用遍历d,我们可以利用d^3=a^ ...

  7. 【题解】「SP867」 CUBES - Perfect Cubes

    这道题明显是一道暴力. 暴力枚举每一个 \(a, b, c, d\) 所以我就写了一个暴力.每个 \(a, b, c, d\) 都从 \(1\) 枚举到 \(100\) #include<ios ...

  8. Zerojudge解题经验交流

    题号:a001: 哈囉 背景知识:输出语句,while not eof 题号:a002: 簡易加法 背景知识:输出语句,while not eof,加法运算 题号:a003: 兩光法師占卜術 背景知识 ...

  9. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  10. HOJ题目分类

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

随机推荐

  1. BZOJ 1567: [JSOI2008]Blue Mary的战役地图( 二分答案 + hash )

    二分答案, 然后用哈希去判断... ------------------------------------------------------------------------- #include ...

  2. Servlet乘法表学习笔记

    一.控制台实现乘法表 package com.shanrengo; import java.io.IOException; import java.io.PrintWriter; import jav ...

  3. jQuery源码,匿名函数自执行

    jQuery框架的首尾是这样写的()(), (function(window){//这个window是个入参,随便起个名字都行 //这里面全都是js代码 })(window)//这个括号里的windo ...

  4. YII2 使用js

    1.在 /backend/assets/ 中新建一个文件 CollectionAsset.php <?php /** * @link http://www.yiiframework.com/ * ...

  5. apache下的IfModule里设置含义

    <IfModule mod_deflate.c> SetOutputFilter DEFLATE #必须的,就像一个开关一样,告诉apache对传输到浏览器的内容进行压缩 SetEnvIf ...

  6. os.path.exists(path) 和 os.path.lexists(path) 的区别

    使用os.path.exists()方法可以直接判断文件是否存在.代码如下:>>> import os>>> os.path.exists(r'C:\1.TXT') ...

  7. Courses(最大匹配)

    Courses Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total S ...

  8. Jquery - checked 全选与取消全选

    html: <!DOCTYPE html> <html> <head> <title>节点列表</title> <link rel=& ...

  9. c++,给常成员变量赋值

    C++中,常成员变量只能在构造函数赋值,且只能通过参数列表的形式赋值,且必须在构造函数赋值. (拥有常成员变量的类的构造函数必须对所有成员变量赋值.) #include <iostream> ...

  10. [Swust OJ 585]--倒金字塔(LIS最长不下降子序列)

    题目链接:http://acm.swust.edu.cn/problem/585/ Time limit(ms): 3000 Memory limit(kb): 65535   SWUST国的一支科学 ...