mringg的天空,自由,自在  
日历
<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011
统计
  • 随笔 - 6
  • 文章 - 0
  • 评论 - 0
  • 引用 - 0

导航

常用链接

留言簿

随笔分类

随笔档案

相册

搜索

  •  

最新评论

阅读排行榜

评论排行榜

 

2010年2月9日

 1#include<cstdio>
 2#include<cstring>
 3#include<iostream>
 4using namespace std;
 5
 6const int dir[2][4]={{-1,-1,0,0},{-1,0,-1,0}};
 7int F[120][60][60],a[60][60];
 8int n,m;
 9int Max(int x,int y)
10{
11    if (x>y) return x;
12    else return y;
13}

14int Min(int x,int y)
15{
16    if (x>y) return y;
17    else return x;
18}

19int 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
posted @ 2010-02-09 15:59 mringg 阅读(252) | 评论 (0)编辑 收藏
 
 1#include<iostream> 
 2using namespace std; 
 3int 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
posted @ 2010-02-09 15:58 mringg 阅读(174) | 评论 (0)编辑 收藏
 
 1#include <iostream>
 2#include <string>
 3using namespace std;
 4int 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
posted @ 2010-02-09 15:57 mringg 阅读(601) | 评论 (0)编辑 收藏
 
 1void 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}

24void quicksort(int* pData,int count)
25{
26     run (pData,0,count-1);
27}
posted @ 2010-02-09 15:56 mringg 阅读(224) | 评论 (0)编辑 收藏
 
 1/*
 2ID:mringg2
 3PROG:ride
 4LANG:C++
 5*/

 6#include <fstream>
 7using namespace std;
 8int 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}
posted @ 2010-02-09 15:43 mringg 阅读(163) | 评论 (0)编辑 收藏

2010年1月17日

 第一篇
posted @ 2010-01-17 05:43 mringg 阅读(117) | 评论 (0)编辑 收藏
 
Copyright © mringg Powered by: 博客园 模板提供:沪江博客