随笔分类 - 基础算法
摘要:最简单的并查集。。。 代码: #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int pre[1200]; int mark[1300]; int find(int x){ return pr
阅读全文
摘要:规律题,如果多写出几组数据就可以找出规律了。。。。 代码: #include<stdio.h> #include<string.h> __int64 num[1200000]; int main(){ __int64 n; int i,j,k,t; memset(num,0,sizeof(num))
阅读全文
摘要:我想到的根本都不是背包问题,看来是我想得太简单了。。。 代码,借鉴别人的 #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; struct node{ int p,h,c,value; }s[30
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=68 看的大神的解析:http://blog.csdn.net/sjl_leaf/article/details/8789785 #include<stdio.h> #include<stri
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=125 题目不经过自己调试ac的不算ac.... #include<stdio.h> #include<string.h> int main(){ int n,m; int i,j,k,t,a
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=469 规律题,找到规律的话就不难了,但是找不到规律的话就不知道从何下手了。。。。。。 #include<stdio.h> #include<string.h> int main(){ int
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=914 二分法加贪心,不理解的可以上网上搜大神的。。。。。。 代码: #include<stdio.h> #include<string.h> #include<algorithm> usin
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=524 对字符串进行比较的一道题目 #include<stdio.h> #include<string.h> char str1[120],str2[120]; int havepoint(c
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=16 有好几天都没有做题目了,本来自己就太弱,还不勤加练习,沉沦了一段时间,想想还是做题好 ,那样的话,充实 这道题目用的是动态,感觉之前好像做过 代码: #include<stdio.h>
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=214 用之前的方法会超时,看了网上的大神的做法,要用到二分法,二分插入法 代码: #include<stdio.h> #include<string.h> #define min -9999
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=49 代码: #include<stdio.h> #include<string.h> #define max(a,b) a>b?a:b int main(){ int du[230],val
阅读全文
摘要:题目链接: hdu 1513:http://acm.hdu.edu.cn/showproblem.php?pid=1513 nyoj 37:http://acm.nyist.net/JudgeOnline/problem.php?pid=37 nyoj 36:http://acm.nyist.net
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=171 动态规划 代码: #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int m
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=17 跟做的上一道题目几乎一样,关键地方的代码改一下就行了 代码: #include<stdio.h> #include<string.h> #include<algorithm> using
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=79 代码: #include<stdio.h> #include<string.h> int main(){ int dp[30],num[30]; int ans,temp,i,j,k,t
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=76 斐波那数列 代码: #include<stdio.h> #include<string.h> int main(){ int num[45]; int n,m; int i,j,k,t;
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=456 0-1背包问题,现在发现我对0-1背包问题有点理解了 我的代码: #include<stdio.h> #include<string.h> #include<algorithm> us
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=289 0-1背包水过~~ 我的代码: #include<stdio.h> #include<string.h> #include<algorithm> using namespace std
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=325 本道题目使用的是0-1背包,不过貌似用0-1背包效果不怎么好,参考别人的代码险过~ 我的代码: #include<stdio.h> #include<string.h> #includ
阅读全文
摘要:题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=269 其实使用0-1背包不怎么熟练,看完这个讲解后才算是对这道题目理解了: http://blog.csdn.net/u013050857/article/details/38373119
阅读全文