摘要: http://ac.jobdu.com/problem.php?id=1395完全背包View Code 1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 using namespace std; 5 int item[60]; 6 int dp[500008]; 7 int main() 8 { 9 int n;10 while(scanf("%d",&n)==1)11 {12 int i,j,sum=0;13 for(i=1;i<=n;i++) s 阅读全文
posted @ 2012-04-01 10:33 keepmoving89 阅读(279) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1040简单排序View Code 1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 const int N=1008; 5 int a[N]; 6 int main() 7 { 8 int t; 9 cin>>t;10 while(t--)11 {12 int n,i;13 cin>>n;14 for(i=0;i<n;i++) cin>>a[i];1... 阅读全文
posted @ 2012-03-31 21:22 keepmoving89 阅读(172) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1035 模拟View Code 1 #include<iostream> 2 #include<cstring> 3 #include<cstdlib> 4 using namespace std; 5 const int N=200; 6 char mat[N][N]; 7 int step[N][N];//到达改点的步数 8 int n,m,s; 9 void initMat()10 {11 for(int i=0;i<N;i++)12 for(int j=0;j 阅读全文
posted @ 2012-03-31 17:08 keepmoving89 阅读(138) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1034 模拟题View Code 1 #include<iostream> 2 using namespace std; 3 int a[100000]; 4 int b[100000];//a的一半 5 int n; 6 int main() 7 { 8 while(cin>>n && n) 9 {10 int i;11 for(i=0;i<n;i++) cin>>a[i];12 int num=0;13 ... 阅读全文
posted @ 2012-03-30 23:14 keepmoving89 阅读(174) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1325 并查集View Code 1 #include<iostream> 2 using namespace std; 3 struct node 4 { 5 int x,y; 6 }; 7 node edge[1000008];//edge 8 int father[1008]; 9 int n,m,k;10 void initSet()11 {12 for(int i=0;i<=n;i++) father[i]=i;13 }14 int find(int x)15 {16 int i=x,temp. 阅读全文
posted @ 2012-03-30 19:34 keepmoving89 阅读(302) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2012-03-30 16:10 keepmoving89 阅读(152) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1016大数相加原理View Code 1 /*大数相加原理*/ 2 #include<iostream> 3 #include<vector> 4 #include<cmath> 5 #include<cstring> 6 #include<algorithm> 7 #include<cstdlib> 8 using namespace std; 9 vector<int>prime; 10 vector<int>v1;// 1 阅读全文
posted @ 2012-03-30 11:20 keepmoving89 阅读(246) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1032 简单模拟View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<iostream> 4 using namespace std; 5 int getnum(long long n) 6 { 7 int num=1; 8 while(n!=1) 9 {10 if(n&1) n=3*n+1;11 else n/=2;12 num++;13 }14 retur... 阅读全文
posted @ 2012-03-30 10:21 keepmoving89 阅读(131) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1398 注意可能有多个最大最小值,找出最左的最小值和最右的最大值即可,用cout超时View Code 1 #include<iostream> 2 #include<climits> 3 #include<cstdio> 4 using namespace std; 5 int a[208]; 6 int main() 7 { 8 int n; 9 while(scanf("%d",&n)==1)10 {11 int i;12 for(i=0;i<n; 阅读全文
posted @ 2012-03-30 09:30 keepmoving89 阅读(145) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1085 母函数View Code 1 /*母函数*/ 2 #include<iostream> 3 #include<cstring> 4 using namespace std; 5 const int N=20000; 6 int c1[N],c2[N];//c[i]是x的i次方的系数 7 int num1,num2,num3; 8 void multiply() 9 {10 memset(c2,0,sizeof(c2));11 memset(c1,0,sizeof(c1));12 阅读全文
posted @ 2012-03-29 22:34 keepmoving89 阅读(125) 评论(0) 推荐(0) 编辑