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 ...
随机推荐
- H5网站加载速度优化总结
1. 在代码文件结构 尽量优化的同时,能力再强已经到极限了,但你服务器辣鸡,搭配不当,你代码优化上天 也是徒劳啊. 2.你不怎么优化, 服务器 各种技术配置到位的话, now你也看到了,我一个系统首页 ...
- BootStrap的基本使用
bootstrap 现成的css样式,直接调用类作用是快速写出页面又称UI框架Bootstrap中文网LESS是预处理器CSS预处理器定义了一种新的语言,基本的思想是用一种专门的编程语言,开发者只需要 ...
- Android 滑动RecyclerView时隐藏部分控件
在使用RecyclerView控件时,上下拖动控件时的时候,需要实时的隐藏与显示部分控件,已到达很好的用户体验. 原理很简单,当RecyclerView拖动至最上层时显示控件,当RecyclerV ...
- cp参数详解
-a 相当于pdr的意思 -d 若原文件为连接文件,则复制链接文件属性,而非文件本身 -f 强制复制,有重复时,不询问用户,而直接强制复制 -i 目标文件存在的话,先询问 -p 与文件的属性一起复制 ...
- K-means、KNN学习笔记
1.K-means:聚类算法,无监督 输入:k, data[n]; (1) 选择k个初始中心点,例如c[0]=data[0],…c[k-1]=data[k-1]; (2) 对于data[0]….dat ...
- (十)maven之排除冲突jar包
排除冲突jar包 jar包冲突 <dependencies> <dependency> <groupId>org.springframework</group ...
- Objective-C分类 (category)和扩展(Extension) 的区别
http://blog.csdn.net/yhawaii/article/details/6992094 http://blog.163.com/wangy_0223/blog/static/4501 ...
- 树形dp——Tree2cycle
一.问题描述(题目链接) 给你一棵树,删除或添加一条边的费用都是1,问使它变成一个环的最小费用. 二.解题思路 回溯法,然后回溯的时候的当前节点度数>2(如果是成环的话肯定就是2或者小于2)就把 ...
- 实 Jordan 标准型和实 Weyr 标准型
将学习到什么 本节讨论关于实矩阵的实形式的 Jordan 标准型,也讨论关于复矩阵的另外一种形式的 Jordan 标准型,因为它在与交换性有关的问题中很有用. 实 Jordan 标准型 假设 \( ...
- iOS UI 设计
优设 http://www.uisdc.com Sketch http://www.sketchcn.com