Follows 573.c (Total 29 lines):

/* @JUDGE_ID:4461XX 573 C */
/* A */
#include<stdio.h>
void main( void )
{
	int day ;
	double h , u , d , f , dis , u1 ;
	while( 1 ){
		scanf( "%lf %lf %lf %lf" , &h , &u , &d , &f ) ;
		if( !h ) break ;
		u1 = u ;
		for( dis=0.0 , day=1 ; ; day++ ){
			dis += u ;
			if( dis > h ){
				printf( "success on day %d\n" , day ) ;
				break ;
			}
			else{
				dis -= d ;
				if( dis < 0.0 ){
					printf( "failure on day %d\n" , day ) ;
					break ;
				}
			}
			u = u - u1 * f / 100.0 ;
			if( u<0.0 ) u = 0.0 ;
		}
	}
}

Back to statistics
Ya-Lin Huang (C)
huangyl@gmail.com