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

WA的太痛苦了, 求助!!!!!!!!!!

Posted by anonym11 at 2004-12-01 21:31:43 on Problem 1150
我的代码:
#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:
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