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 一个AC

Posted by tcxgsy at 2006-11-05 20:19:04 on Problem 3014
Source

Problem Id:3014  User Id:tcxgsy 
Memory:128K  Time:1280MS
Language:C++  Result:Runtime Error

Source 

#include <iostream>
using namespace std;

int f[2][4510];

int main () 
{
    int n,m,a,b,i,j,k,rs;
    while(scanf("%d%d",&n,&m)!=EOF)
	{
        a=1 ; 
        b=0 ;
       // memset ( f , 0 , sizeof ( f ) ) ;
		for(i=0;i<=1;i++)
			for(j=0;j<4510;j++)
				f[i][j]=0;

        for (i=0;i<=m;i++) 
			f[1][i]=1 ;

        for (k=2;k<=n;k++) 
		{
            for( i=0;i<=m;i++) 
			{
                if ( i >= k ) 
				{
					f[b][i]=f[a][i]+f[b][i-k] ;      
					if(f[b][i]>1000000007)
						f[b][i] -= 1000000007 ;
				}
				else
					f[b][i] = f[a][i];
			}
            a=1-a;
            b=1-b;
		}
        printf("%d\n" , f[a][m] ) ;
    }
    return 0;
}

第二个
Source

Problem Id:3014  User Id:tcxgsy 
Memory:128K  Time:4765MS
Language:C++  Result:Accepted

Source 

#include <iostream>
using namespace std;

int f[2][4510];

int main () 
{
    int n,m,a,b,i,j,k,rs;
    while(scanf("%d%d",&n,&m)!=EOF)
	{
        a=1 ; 
        b=0 ;
       // memset ( f , 0 , sizeof ( f ) ) ;
		for(i=0;i<=1;i++)
			for(j=0;j<4510;j++)
				f[i][j]=0;

        for (i=0;i<=m;i++) 
			f[1][i]=1 ;

        for (k=2;k<=n;k++) 
		{
            for( i=0;i<=m;i++) 
			{
                if ( i >= k ) 
				{
					f[b][i]=f[a][i]+f[b][i-k] ;      
					if(f[b][i]>1000000007)
						f[b][i] -= 1000000007 ;
				}
				else
					f[b][i] = f[a][i];
			}
            a=1-a;
            b=1-b;
		}
        printf("%d\n" , f[a][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