日历
| 日 | 一 | 二 | 三 | 四 | 五 | 六 |
---|
31 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
|
统计
- 随笔 - 6
- 文章 - 0
- 评论 - 0
- 引用 - 0
导航
常用链接
留言簿
随笔分类
随笔档案
相册
搜索
最新评论

阅读排行榜
评论排行榜
|
2010年2月9日
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 using namespace std; 5 6 const int dir[2][4]= { {-1,-1,0,0}, {-1,0,-1,0}}; 7 int F[120][60][60],a[60][60]; 8 int n,m; 9 int Max(int x,int y) 10  { 11 if (x>y) return x; 12 else return y; 13 } 14 int Min(int x,int y) 15  { 16 if (x>y) return y; 17 else return x; 18 } 19 int main() 20  { 21 scanf("%d%d",&n,&m); 22 for (int i=1;i<=n;i++) 23 for (int j=1;j<=m;j++) 24 scanf("%d",&a[i][j]); 25 memset(F,0,sizeof(F)); 26 int x; 27 for (int k=2;k<=n+m;k++) 28 for (int i1=1;i1<=Min(n,k-1);i1++) 29 for (int i2=1;i2<=Min(n,k-1);i2++) 30 { 31 x=a[i1][k-i1]+a[i2][k-i2]; 32 if (i1==i2) x=a[i1][k-i1]; 33 for (int i=0;i<=3;i++) 34 F[k][i1][i2]=Max(F[k][i1][i2],F[k-1][i1+dir[0][i]][i2+dir[1][i]]); 35 F[k][i1][i2]+=x; 36 } 37 printf("%d\n",F[n+m][n][n]); 38 return 0; 39 } 40
1 #include<iostream> 2 using namespace std; 3 int main() 4  { 5 int time=0,num=0,mtime[1001]= {},mmoney[101]= {},f[10001]= {}; 6 cin>>time>>num; 7 for(int i=1;i<=num;i++) 8 { 9 cin>>mtime[i]>>mmoney[i]; 10 } 11 for(int i=1;i<=num;i++) 12 { 13 for(int j=time;j>=mtime[i];j--) 14 { 15 f[j]=max(f[j],f[j-mtime[i]]+mmoney[i]); 16 } 17 } 18 cout<<f[time]<<endl; 19 system ("pause"); 20 return 0; 21 } 22
1 #include <iostream> 2 #include <string> 3 using namespace std; 4 int main() 5  { 6 string word; 7 int zero=0; 8 int abc[26]= {}; 9 cin>>word; 10 for (int i=0;i<word.size();i++) 11 { 12 ++abc[word[i]-'a']; 13 } 14 int maxword=-1,minword=999999; 15 for (int i=0;i<26;i++) 16 { 17 if (abc[i]>maxword) maxword=abc[i]; 18 } 19 for (int i=0;i<26;i++) 20 { 21 if (abc[i]<minword&&abc[i]!=0) minword=abc[i]; 22 } 23 int cha; 24 cha=maxword-minword; 25 if (cha==2||cha==3||cha==5||cha==7||cha==11||cha==13||cha==17||cha==19||cha==23||cha==29||cha==31||cha==37||cha==41||cha==43||cha==47||cha==53) 26 { 27 cout<<"Lucky Word"<<endl; 28 cout<<cha<<endl; 29 } 30 else 31 { 32 cout<<"No Answer"<<endl; 33 cout<<zero<<endl; 34 } 35 system ("pause"); 36 return 0; 37 } 38
1 void run(int* pData,int left,int right) 2  { 3 int i,j; 4 int middle,iTemp; 5 i=left; 6 j=right; 7 middle=pData[(left+right)/2]; 8 do 9 { 10 while ((pData[i]<middle)&&(i<right)) i++; 11 while ((pData[j]>middle)&&(j>left)) j--; 12 if (i<=j) 13 { 14 iTemp=pData[i]; 15 pData[i]=pData[j]; 16 pData[j]=iTemp; 17 i++; 18 j--; 19 } 20 }while (i<=j); 21 if (i<right) run (pData,i,right); 22 if (j>left) run (pData,left,j); 23 } 24 void quicksort(int* pData,int count) 25  { 26 run (pData,0,count-1); 27 }
1 /**//* 2 ID:mringg2 3 PROG:ride 4 LANG:C++ 5 */ 6 #include <fstream> 7 using namespace std; 8 int main() 9  { 10 ifstream fin("ride.in"); 11 ofstream fout("ride.out"); 12 char a[7]= {'A','A','A','A','A','A','A'},b[7]= {'A','A','A','A','A','A','A'}; 13 fin>>a; 14 fin>>b; 15 int n=sizeof(a); 16 int aNum=1,bNum=1; 17 for(int i=0;i<n;i++) 18 { 19 aNum=aNum*(a[i]-'A'+1); 20 bNum=bNum*(b[i]-'A'+1); 21 } 22 aNum=aNum%47; 23 bNum=bNum%47; 24 if(aNum==bNum) fout<<"GO"<<endl; 25 else fout<<"STAY"<<endl; 26 return 0; 27 }
2010年1月17日
|