| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Output Limit Exceeded求救!!!我的程序就是说Output Limit Exceeded,不知为什么?大牛帮看看,感激不尽!!!
Source CodeProblem: 1384 User: zhongwen
Memory: N/A Time: N/A
Language: C++ Result: Output Limit Exceeded
Source Code
#include <cstdio>
#include <cstring>
int ca , s , e , a[500][2] , f[10000] , m , n ;
int main()
{
int i , j , k ;
scanf( "%d" , &ca ) ;
while ( ca )
{
scanf( "%d%d" , &s , &e ) ;
n = e-s ;
scanf( "%d" , &m ) ;
memset( f , 127 , sizeof(f) ) ; f[0] = 0 ;
for ( i = 0 ; i < m ; i++ )
scanf( "%d%d" , &a[i][0] , &a[i][1] ) ;
for ( i = 0 ; i < m ; i++ )
for ( j = 0 ; j <= n ; j++ )
if ( f[j] != 2139062143 )
for ( k = 1 ; k <= n/a[i][1] ; k++ )
if ( f[j+k*a[i][1]] > f[j]+k*a[i][0] ) f[j+k*a[i][1]] = f[j]+k*a[i][0] ;
if ( f[n] == 2139062143 ) printf( "This is impossible.\n" ) ;
else printf( "The minimum amount of money in the piggy-bank is %d.\n" , f[n] ) ;
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator