HDU 1016 Prime Ring Problem
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1016DFS的经典题#include#includeusing namespace std;int ring[25];bool prime[45];bool visit[25];void isprime(in...
阅读全文
HDU 4310 Hero
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=4310按比值排序:dps/hp...为了避免小数出现cmp函数写成相乘的形式#include #includeusing namespace std;class hero{public: int hp;...
阅读全文
素数筛选法<单向链表实现>
摘要:#include using namespace std;struct note{ int data; note *next;};class listprime{private: note *head;public: listprime(int n); void Del...
阅读全文
POJ 3253 Fence Repair
摘要:链接:http://poj.org/problem?id=3253每次都找出最短的两个合并..优先队列#include #includeusing namespace std;int main(){ int n; int i; int t; int a,b; long ...
阅读全文
POJ 2431 Expedition
摘要:链接:http://poj.org/problem?id=2431当燃料用完后,选择经过的所有加油站中能加的油最多的..所以,在之后需要加油时,就认为在之前经过的加油站加油就可以了..优先队列#include #include#includeusing namespace std;class fue...
阅读全文
NYOJ 269 VF
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=269求1~10^9间各位相加和为s的数的个数..dp[i][j]:::前i位和为j的数字的个数 #include using namespace std;int dp[11][90];void ...
阅读全文
NYOJ 456 邮票分你一半
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=456价值与重量相等的01背包..背包的容量为邮票总和的一半#include #include#include#includeusing namespace std;int dp[500005];...
阅读全文
划分数问题 DP
摘要:《挑战程序设计竞赛》2.3.3:有n个无区别的物品,将他们划分成不超过m组,求出划分方法数模M的余数称做n的m划分,dp定义如下:dp[ i ] [ j ] =j的i划分的总数;考虑n的m划分ai (a1+a2+a3+...+am ==n) ,对于每个i都有ai>0,,So..{ai-1} 也就对应...
阅读全文
HDU 1253 胜利大逃亡
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1253宽度优先搜索:#include #include#include#define INF 10000000using namespace std;class p{public: int x; ...
阅读全文
NYOJ 294 Bot Trust
摘要:链接: http://acm.nyist.net/JudgeOnline/problem.php?pid=294一步一步模拟出来的....把情况考虑全面: “Both robots know the full sequence in advance” #include #include#includ...
阅读全文
NYOJ 36 最长公共子序列
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=36经典dp题:#include #includeusing namespace std;int dp[1005][1005];char a[1005];char b[1005];int main...
阅读全文
HDU 1555 How many days?
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1555模拟一下就行了..注意不要忘了musing namespace std;int main(){ int m,k; int ans; while(cin>>m>>k&&m+k!=0) ...
阅读全文