POJ 1887 Testing the CATCHER
摘要:1 Source Code 2 3 Problem: 1887 User: XXX 4 Memory: 240K Time: 63MS 5 Language: C++ Result: Accepted 6 7 Source Code 8 #include <stdio.h> 9 int main()10 {11 int num[10000] ,total ,i ,j ,k ,Max ,max ,dp[10000] = {1};12 for(k = 1 ; ;k++)13 {14 total = -1 ,Max = 1;15...
阅读全文
posted @
2012-02-26 11:30
小墨在努力!!
阅读(185)
推荐(0)
POJ 1088 滑雪
摘要:感觉有点水啊,不过我怎么感觉自己没呢dp的思维啊 1 Source Code 2 3 Problem: 1088 User: XXX 4 Memory: 248K Time: 0MS 5 Language: C++ Result: Accepted 6 7 Source Code 8 #include <stdio.h> 9 #include <string.h>10 int num[102][102] ,dp[102][102];11 int slove(int i ,int j)12 {13 if(dp[i][j] != -1) return dp[i][j];..
阅读全文
posted @
2012-02-25 14:02
小墨在努力!!
阅读(199)
推荐(0)
POJ 3356
摘要:都是最长公共子序列。。。。水题,前面的代码就没呢改,加了一个变量就过了,不解释Source CodeProblem: 3356 User: XXXMemory: 172K Time: 16MS Language: C++ Result: Accepted Source Code #include <stdio.h>#include <string.h>int main(){ char str1[1005] ,str2[1005]; int len1 ,len2 ,len ,i ,j ,dp[2][1005]; while(scanf("%d %s %d %s.
阅读全文
posted @
2012-02-17 13:30
小墨在努力!!
阅读(188)
推荐(0)
POJ 1080 Human Gene Functions
摘要:Source CodeProblem: 1080 User: XXXMemory: 204K Time: 0MS Language: C++ Result: Accepted Source Code #include <stdio.h>#include <string.h>int max(int a ,int b ,int c){ if(a >= b && a >= c) return a; else if(b >= a && b >= c) return b; else return c;}int main(){
阅读全文
posted @
2012-02-16 23:11
小墨在努力!!
阅读(152)
推荐(0)
POJ 1159 Palindrome
摘要:Source CodeProblem: 1159 User: XXXMemory: 204K Time: 750MS Language: C++ Result: Accepted Source Code #include <stdio.h>#include <string.h>int main(){ char str[5005]; int n[2][5006] ,i ,j ,m; while(scanf("%d",&m) != EOF) { scanf("%s",str); memset(n ,0 ,si...
阅读全文
posted @
2012-02-14 23:53
小墨在努力!!
阅读(135)
推荐(0)
POJ 1458 Common Subsequence
摘要:这几天一直在做水题,各种水题,自己果然很水。。。。。开一个二维数组。。1458Accepted1148K16MSC++778B2012-02-13 23:43:52#include <stdio.h>#include <string.h>int main(){ char a[500] ,b[500]; int n[501][501] ,len1 ,len2 ,i ,j; for(i = 0 ;i <= 500 ;i++) n[0][i] = n[i][0] = 0; while(scanf("%s%s",a ,b) != EOF) ...
阅读全文
posted @
2012-02-13 23:50
小墨在努力!!
阅读(212)
推荐(0)
HDU 1024
摘要:态转移方程: dp[i][j]=max{dp[i][j-1]+A[j],dp[i-1][t]+a[j] (i-1<=t<n-m+i) }#include <stdio.h>#include <string.h>int num[1000050] ,pre[1000050] ,now[1000050];int main (){ long int m ,n ,max_pre; while (scanf("%d%d",&m,&n) != EOF) { for (int i = 1 ;i <= n ;i++) scanf(&q
阅读全文
posted @
2012-02-13 18:58
小墨在努力!!
阅读(1082)
推荐(0)
hdu 1004
摘要:map的使用,还不是很会用啊。。。。#include <iostream>#include <string>#include <map>using namespace std;int main(){ int n; string s,s2; while(scanf("%d",&n)&&n!=0) { map <string,int> m; map <string,int> :: iterator p; for (int i = 1;i <= n;i++) { ...
阅读全文
posted @
2012-02-13 18:52
小墨在努力!!
阅读(153)
推荐(0)
hdu 1002
摘要:高精度。。。。#include <stdio.h>#include <string.h> int sum[1000];void add (char a[] ,char b[]){ int i = strlen(a) - 1 ,j = strlen (b) - 1; int x = 0 ,s ,k = 0; while (i >= 0 && j >= 0) { s = a[i--] + b[j--] - 96 + x ; sum[k++] = s % 10 ; x = s / 10 ; } ...
阅读全文
posted @
2012-02-13 18:50
小墨在努力!!
阅读(145)
推荐(0)
POJ 1579
摘要:记忆化搜索。。。。。http://poj.org/problem?id=1579#include <stdio.h>#define max 32767int w[21][21][21];int funtion(int a ,int b ,int c){ if(a <= 0 || b <= 0 || c <= 0) return 1; else if(a > 20 || b > 20 || c > 20) { if(w[20][20][20] == max) w[20][20][20] = funtion(2...
阅读全文
posted @
2012-02-11 10:41
小墨在努力!!
阅读(291)
推荐(0)
POJ 1006
摘要:中国古代求解一次同余式组(见同余)的方法。是数论中一个重要定理。又称中国剩余定理。公元前后的《孙子算经》中有“物不知数”问题:“今有物不知其数,三三数之余二 ,五五数之余三 ,七七数之余二,问物几何?” 解法中的三个关键数70,21,15,有何妙用,有何性质呢?首先70是3除余1而5与7都除得尽的数,所以70a是3除余a,而5与7都除得尽的数,21是5除余1,而3与7都除得尽的数,所以21b是5除余b,而3与7除得尽的数。同理,15c是7除余c,3与5除得尽的数,总加起来 70a+21b+15c 是3除余a,5除余b ,7除余c的数,也就是可能答案之一,但可能不是最小的,这数加减105(105
阅读全文
posted @
2012-02-01 20:50
小墨在努力!!
阅读(227)
推荐(0)