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

这个题目 如果都算出来的话,精确统计可是超时了阿代码如下 应该怎么做阿,

Posted by first at 2003-12-13 16:54:05 on Problem 1423
#include<iostream>
using namespace std;
#define MAX_DIG 60000 
/* Max digit is 60000 x 2 = 120,000  :) */ 
void main() 
{ 
    unsigned char N[MAX_DIG]; 
    register unsigned int i, j; 
    long int pN, last0 = 0; 
    register unsigned int sum = 0; 
    int times,n; 
	digits[0]=1;
	cin>>times;
	while(times--)
	{
		cin>>n;
		N[0]=1; 
		last0=0;
		pN=0; 
		for (j=2; j<=n; j++) 
		{ 
			sum = 0; 
			for (i=last0; i<=pN; i++) 
			{ 
				sum = sum + N[i] * j; 
				N[i] = sum % 100; 
				sum = sum / 100; 
			} 
			while (sum>0) 
			{ 
				pN++; 
				N[pN] = sum % 100; 
				sum = sum / 100; 
			} 
			while ((N[last0] == 0) && (last0<pN)) 
				last0++; 
		} 
		if(N[pN]<10)
			cout<<pN*2+1<<endl;
		else
			cout<<pN*2+2<<endl; 
	}
	
} 

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