Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:DP第一次AC

Posted by makuiyu at 2014-01-02 22:31:00 on Problem 1157
In Reply To:DP第一次AC Posted by:shoutz at 2013-04-10 14:37:20
> 庆祝一下~
> #include<iostream>
> #include<algorithm>
> using namespace std;
> int main()
> {
>     int f,v;
>     int a[110][110];
>     int b[110][110];
>     for(int i=0;i<100;i++)
>         for(int j=0;j<100;j++)
>         b[i][j]=-100000;
> 
>     while(cin>>f>>v)
>     {
> 
>         for(int i=0;i<f;i++)
>             for(int j=0;j<v;j++)
>             cin>>a[i][j];
>         b[0][0]=a[0][0];
>         for(int i=1;i<v;i++)
>         {
>             b[0][i]=max(b[0][i-1],a[0][i]);
>         }
>         for(int i=1;i<f;i++)
>             for(int j=i;j<v;j++)
>         {
>             b[i][j]=max(b[i-1][j-1]+a[i][j],b[i][j-1]);
>         }
>         cout<<b[f-1][v-1]<<'\n';
> 
>     }
> }

数组b的初始化应该放在while循环体内。因为这题是单组测试用例,所以你的代码能A。不过感谢dp公式!!!

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator