hdu1334-Perfect Cubes
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的更多相关文章
- poj 1543 Perfect Cubes(注意剪枝)
Perfect Cubes Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 14901 Accepted: 7804 De ...
- OpenJudge 2810(1543) 完美立方 / Poj 1543 Perfect Cubes
1.链接地址: http://bailian.openjudge.cn/practice/2810/ http://bailian.openjudge.cn/practice/1543/ http:/ ...
- POJ 1543 Perfect Cubes
Perfect Cubes Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 12595 Accepted: 6707 De ...
- poj 1543 Perfect Cubes (暴搜)
Perfect Cubes Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 15302 Accepted: 7936 De ...
- HDOJ 1334 Perfect Cubes(暴力)
Problem Description For hundreds of years Fermat's Last Theorem, which stated simply that for n > ...
- ZOJ Problem Set - 1331 Perfect Cubes 判断一个double是否为整数
zju对时间要求比较高,这就要求我们不能简单地暴力求解(三个循环搞定),就要换个思路:因为在循环时,已知a,确定b,c,d,在外重两层循环中已经给定了b和c,我们就不用遍历d,我们可以利用d^3=a^ ...
- 【题解】「SP867」 CUBES - Perfect Cubes
这道题明显是一道暴力. 暴力枚举每一个 \(a, b, c, d\) 所以我就写了一个暴力.每个 \(a, b, c, d\) 都从 \(1\) 枚举到 \(100\) #include<ios ...
- Zerojudge解题经验交流
题号:a001: 哈囉 背景知识:输出语句,while not eof 题号:a002: 簡易加法 背景知识:输出语句,while not eof,加法运算 题号:a003: 兩光法師占卜術 背景知识 ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- HOJ题目分类
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
随机推荐
- BZOJ 1639: [Usaco2007 Mar]Monthly Expense 月度开支( 二分答案 )
直接二分答案然后判断. ----------------------------------------------------------------------------- #include&l ...
- fork 函数的一点学习
昨天某位少年问了我一个问题,#include<stdio.h> int main() { fork(); fork(); fork(); printf("hello " ...
- 解析request的反馈信息
Map<String,String> params = new HashMap<String,String>(); Map requestParams = request.ge ...
- pageContext.request.contextPath 和 request.getContextPath()
作用是取出部署的应用程序名,这样不管如何部署,所用路径都是正确的. El表达式的写法:${pageContext.request.contextPath} jsp的写法:<%=request.g ...
- web.py入门
官网介绍: web.py is a web framework for Python that is as simple as it is powerful. web.py is in the pub ...
- 开发记录_自学Python写爬虫程序爬取csdn个人博客信息
每天刷开csdn的博客,看到一整个页面,其实对我而言,我只想看看访问量有没有上涨而已... 于是萌生了一个想法: 想写一个爬虫程序把csdn博客上边的访问量和评论数都爬下来. 打算通过网络各种搜集资料 ...
- 文本图片自适应高度小bug以及解决办法
自定义cell的文本图片自适应高度代码,如果存在自定义的cell赋值封装,就必须将自适应高度代码写在这个方法中 点击效果: 注:- (void)layoutSubviews 方法不能同时操作,否则会出 ...
- iOS中正确的截屏姿势
昨天写了个用到截屏功能的插件,结果问题不断,今天终于解决好了,把debug过程中所有尝试过的截屏方法都贴出来吧- 第一种 这是iOS 3时代开始就被使用的方法,它被废止于iOS 7.iOS的私有方法, ...
- ActionBar点击弹出下拉框操作
首先: getActionBar().setDisplayShowTitleEnabled(false); ActionBar.LayoutParams lp = new ActionBar.Layo ...
- MVC自定义AuthorizeAttribute实现权限管理
[转]MVC自定义AuthorizeAttribute实现权限管理 原文载自:小飞的DD http://www.cnblogs.com/feiDD/articles/2844447.html 网站的权 ...