随笔分类 - 未完待续
摘要:1、暴力【代码】: 1 /*HDU1394暴力写法*/ 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 int A[50005]; 9 int Low[50005],Up[50005];10 int main(){...
阅读全文
摘要:1、http://www.spoj.pl/problems/AIBOHP/:dp2、http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=114&page=show_problem&problem=6153、http://acm.hdu.edu.cn/showproblem.php?pid=3639
阅读全文
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1346明天写题解!!!!问题描述:求最长公共子序列1、递推求解:#include#include#include#includeusing namespace std;char s1[1100],s2[1100];int c[1100][1100];int LCS(){ int n=strlen(s1); int m=strlen(s2); memset(c,0,sizeof(c)
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #define mod 1000000007 6 long long dp[1010]; 7 void getdp() 8 { 9 memset(dp,0,sizeof(dp));10 dp[1]=1;11 for(int i=2;i<=1000;i++)12 {13 for(int j=1;j<=i;j++)14 {15 if ((i-1)%j==0) dp[i]+=dp[j],dp[i]=dp[i]%mod;1...
阅读全文
摘要:并查集:我们知道p[x]中存储的是x的根节点,或者说,我们要的目的是所有在一棵树上的节点,他们的p[x]必须是相同的并查集的代码很简单,但在使用时很难达到上述结果,或者说,稍有不慎,就会出错。也许你会说我只要判断find(i)==find(1)都成立就好了,但这往往只能判断一个连通集的问题。所以具体的方法是什么?我们先描述方法,再证明。步骤:int find(int x){return x==p[x]?x:p[x]=find(p[x]);}read(u,v);f1=find(u);f2=find(v);if(f1!=f2) p[f2]=f1;for(i=1;i13423结果: x 1 2 ..
阅读全文