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

不知道这样可不可以a

Posted by 14310320733 at 2015-07-17 19:42:46 on Problem 1157
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int a[101][101],b[101][101];
int main()
{
    int i,j,k;
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        for(i=1; i<=n; i++)
        {
            for(j=1; j<=m; j++)
            {
                scanf("%d",&a[i][j]);
            }
        }
        b[1][1]=a[1][1];
        for(k=2; k<=n; k++)
        {
            b[1][k]=max(a[1][k],b[1][k-1]);
        }
        for(i=2; i<=n; i++)
        {
            b[i][i]=b[i-1][i-1]+a[i][i];
            for(j=i+1; j<=m; j++)
            {
                b[i][j]=max(b[i-1][j-1]+a[i][j],b[i][j-1]);
            }
        }
        printf("%d\n",b[n][m]);
    }
    return 0;
}

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