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 |
WA的太痛苦了, 求助!!!!!!!!!!我的代码: #include<stdio.h> int t2, last; int p2[4] = { 2, 4, 8, 6 }; void comp ( int start, int end ) { while ( start <= end ) { last *= start; while ( last % 10 == 0 ) last /= 10; last %= 10; start ++; } } void compute ( int start, int end ) { if ( start == end ) { comp ( start, end ); return ; } int s, e; s = ( start - 1 ) / 5; s += 1; e = ( end - 1 ) / 5; //printf ( "%d %d %d %d %d\n", start, end, s, e, last ); if ( s >= e ) comp ( start, end ); else { s *= 5; comp ( start, s-1 ); s /= 5; e *= 5; comp ( e+1, end ); e /= 5; t2 += e - s - 1 ; compute ( s, e ); } } int main () { int n, m; while ( scanf ( "%d%d",&n,&m ) != EOF ) { last = 1; t2 = 0; compute ( n-m+1, n ); if ( t2 ) { t2 %= 4; last *= p2[(t2+3)%4] ; } last %= 10; printf ( "%d\n",last ); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator