POJ 1543 Perfect Cubes
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 12595 | Accepted: 6707 |
Description
Input
Output
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)
题目大意:给定一个数n,三个数a,b,c大于1,问n以内有多少个数字满足n^3 = a^3 + b^3 + c^3。
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std; int ans[];
int visted[];
int selected[]; void DFS(int n, int index)
{
if (index == )
{
if (n * n * n == ans[] * ans[] * ans[] + ans[] * ans[] * ans[] + ans[] * ans[] * ans[] && selected[ans[]] * selected[ans[]] * selected[ans[]] == )
{
printf("Cube = %d, Triple = (%d,%d,%d)\n", n, ans[], ans[], ans[]);
selected[ans[]] = selected[ans[]] = selected[ans[]] = ;
}
return;
}
for (int i = ; i < n; i++)
{
if (!visted[i])
{
visted[i] = ;
ans[index] = i;
DFS(n, index + );
visted[i] = ;
}
}
} int main()
{
int n;
scanf("%d", &n);
for (int i = ; i <= n; i++)
{
memset(visted, , sizeof(visted));
memset(selected, , sizeof(selected));
DFS(i, );
}
return ;
}
POJ 1543 Perfect Cubes的更多相关文章
- 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: 14901 Accepted: 7804 De ...
- poj 1543 Perfect Cubes (暴搜)
Perfect Cubes Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 15302 Accepted: 7936 De ...
- POJ 3398 Perfect Service(树型动态规划,最小支配集)
POJ 3398 Perfect Service(树型动态规划,最小支配集) Description A network is composed of N computers connected by ...
- POJ 3905 Perfect Election(2-sat)
POJ 3905 Perfect Election id=3905" target="_blank" style="">题目链接 思路:非常裸的 ...
- POJ 3398 Perfect Service --最小支配集
题目链接:http://poj.org/problem?id=3398 这题可以用两种上述讲的两种算法解:http://www.cnblogs.com/whatbeg/p/3776612.html 第 ...
- HDOJ 1334 Perfect Cubes(暴力)
Problem Description For hundreds of years Fermat's Last Theorem, which stated simply that for n > ...
- POJ 1730 Perfect Pth Powers(暴力枚举)
题目链接: https://cn.vjudge.net/problem/POJ-1730 题目描述: We say that x is a perfect square if, for some in ...
- POJ 3905 Perfect Election (2-Sat)
Perfect Election Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 438 Accepted: 223 De ...
随机推荐
- 《高性能MySQL》读书笔记之 MySQL锁、事务、多版本并发控制的基础知识
1.2 并发控制 1.2.1 读写锁 在处理并发读或写时,通过实现一个由两种类型的锁组成的锁系统来解决问题.这两种类型的锁通常被称为 共享锁(shared lock) 和 排它锁(exclusive ...
- poj2135 最小费用流
添加超级源点(与点1之间的边容量为2,权值为0)和超级汇点(与点N之间的边容量为2,权值为0),求流量为2的最小费用流.注意是双向边. #include <iostream> #inclu ...
- Android 坑爹问题
A/art: art/runtime/jdwp/jdwp_event.cc:] Check failed: Thread::Current() != GetDebugThread() (Thread: ...
- nconf修改密码
修改nconf登录界面密码 [root@Cnyunwei config]# vi .file_accounts.php <?php/*## User/Password file for simp ...
- 洛谷 P2068 统计和
题目描述 给定一个长度为n(n<=100000),初始值都为0的序列,x(x<=10000)次的修改某些位置上的数字,每次加上一个数,然后提出y (y<=10000)个问题,求每段区 ...
- iOS打包上传app store各种问题解决总结
问题1 this action could not be completed. try again 问题2 there was an error sending data to the iTunes ...
- docker安装Tensorflow并使用jupyter notebook
目前网上提供的大多数的方法都是如下: docker pull tensorflow/tensorflow docker run -it -p : tensorflow/tensorflow 但是按照步 ...
- django 2.0 + pycharm2017 出现的问题
在创建完成app之后,在models文件里创建两个类:BlogType , Blog, 创建超级用户,注册admin,在登陆admin之后发现,发现 BlogType , Blog,并没有导入到adm ...
- python之道07
2.用户输入一个数字,判断一个数是否是水仙花数. 水仙花数是一个三位数, 三位数的每一位的三次方的和还等于这个数. 那这个数就是一个水仙花数, 例如: 153 = 1******3 + 5****** ...
- strchr函数
函数原型:extern char *strchr(char *str,char character) 参数说明:str为一个字符串的指针,character为一个待查找字符. 所在库名 ...