随笔分类 - 基础算法
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=252 简单水题 代码: #include<stdio.h> #include<string.h> int main(){ int n,t; int num[120]; memset(num,
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=219 #include<stdio.h> #include<string.h> int main(){ int year,month,day; while(~scanf("%d %d %d"
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1874 弗洛伊德最短路径问题 代码: #include<stdio.h> #include<string.h> #define inf 0x3f3f3f3f #include<algorithm> usi
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=27 代码: <pre name="code" class="cpp">#include<stdio.h> #include<string.h> #include<stdlib.h> int
阅读全文
摘要:题目链接: 搜索题,有两种情况,两种有一种不考虑的话就会WA.... 代码: #include<stdio.h> #include<string.h> #define INF 999999999//定义一个最大的数 #include<algorithm> using namespace std; i
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1015 #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; char zifu[2000],str[20],s
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=254 0-1背包问题 代码: #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int cmp(int a,
阅读全文
摘要:正好我现在在玩数独这个游戏,看到这个问题我就来了兴趣,完成着这个问题,妈妈再也不用担心我玩数独游戏啦~~ 题目链接: http://acm.nyist.net/JudgeOnline/problem.php?pid=722 #include<stdio.h> int map[9][9]; int f
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1010 做这道题目的时候需要注意剪枝,如果没有剪枝的话,就会超时 注意奇偶剪枝 代码:】 #include<stdio.h> #include<string.h> #include<stdlib.h> c
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=58 比较简单的搜索题目, 代码: #include<stdio.h> #include<string.h> int map[9][9]={{1,1,1,1,1,1,1,1,1},{1,0,0
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2152 母函数: 代码: #include<stdio.h> #include<string.h> int main(){ int c1[120],c2[120],min[120],max[120]; i
阅读全文
摘要:简单的背包题 ;好无奈,我又没做出来在考试的时候 代码: #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; double dp[60],money[60]; double total; int
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1241 简单的深搜,但是我花了两个小时都没没有做出来,说出来都是泪啊 代码: #include<stdio.h> #include<string.h> #include<algorithm> using
阅读全文
摘要:Problem Description Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shores of Rellau Creek in central
阅读全文
摘要:Problem Description A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of nu
阅读全文
摘要:Problem Description Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7
阅读全文
摘要:描述 Tom has fallen in love with Mary. Now Tom wants to show his love and write a number on the fence opposite to Mary’s house. Tom thinks that the larg
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=220 贪心算法 主要是除以二的那一点不好想,就是两排房子并行的 http://acm.nyist.net/JudgeOnline/problem.php?pid=220 #include<s
阅读全文
摘要:描述 Here is a famous story in Chinese history. "That was about 2300 years ago. General Tian Ji was a high official in the country Qi. He likes to play
阅读全文
摘要:描述 Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the s
阅读全文