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,帮忙看看是怎么回事

Posted by ds570 at 2017-04-05 19:54:08 on Problem 1050
#include<stdio.h>
int a[130][130];

int longsum(int tmp[],int n){
    int maxn=0,sum=0;
    for(int i=0;i<n;i++){
        sum+=tmp[i];
        if(sum>0){
            if(sum>maxn)maxn=sum;
        }
        else sum=0;
    }
    return maxn;
}

int main(){
    int n;
    int tmp[130];
    while(~scanf("%d",&n)){
        int maxn=0;
        int sig=0,x;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                scanf("%d",&a[i][j]);
            }
        }
        for(int i=n;i>0;i--){
            for(int j=0;j<i;j++){
                for(int m=0;m<n;m++){
                    tmp[m]=a[j][m];
                }
                x=j+1;
                for(int k=0;k<sig;k++){
                    for(int m=0;m<n;m++){
                        tmp[m]+=a[x][m];
                    }
                    x++;
                }
                if(maxn<longsum(tmp,n)){
                    maxn=longsum(tmp,n);
                }
                sig++;
            }
        }
        printf("%d\n",maxn);
    }
    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