小墨在努力!!
吗了个b的。。。。。
摘要: 都是最长公共子序列。。。。水题,前面的代码就没呢改,加了一个变量就过了,不解释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 小墨在努力!! 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 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 小墨在努力!! 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 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 小墨在努力!! 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 这几天一直在做水题,各种水题,自己果然很水。。。。。开一个二维数组。。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 小墨在努力!! 阅读(184) 评论(2) 推荐(0) 编辑
摘要: 态转移方程: 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 小墨在努力!! 阅读(1054) 评论(0) 推荐(0) 编辑
摘要: 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 小墨在努力!! 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 高精度。。。。#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 小墨在努力!! 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 记忆化搜索。。。。。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 小墨在努力!! 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 中国古代求解一次同余式组(见同余)的方法。是数论中一个重要定理。又称中国剩余定理。公元前后的《孙子算经》中有“物不知数”问题:“今有物不知其数,三三数之余二 ,五五数之余三 ,七七数之余二,问物几何?” 解法中的三个关键数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 小墨在努力!! 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 开始打表、二分,结果TLE,发现小型数据二分还不如顺序查找。#include <stdio.h>int main(){ float card[280] = {0 ,0.5} ,c; for(int i = 2 ;i <= 276 ;i++) card[i] = card[i - 1] + 1.0 / (i + 1); while(scanf("%f" ,&c) && c != 0.00) { int i; for(i = 1 ;card[i] < c; i++){} printf("%d card(s)\n... 阅读全文
posted @ 2012-01-28 14:18 小墨在努力!! 阅读(112) 评论(0) 推荐(0) 编辑