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

poj 1019求教一下 为什么 time run error 附上代码

Posted by mabodx at 2010-02-01 14:59:45
#include<stdio.h>
#include<math.h>


long a[32628]={0},s[32628]={0};
void init()
{
	int q;
	for(q=1;q<32629;q++)
	{
		a[q]=a[q-1]+(int)log10((float)q)+1;
		s[q]=s[q-1]+a[q];
	}
}
int main(void)


{
	init();
	int t,i,b,d;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&i);
		for(b=1;s[b]<i;b++);
		i-=s[b-1];
		
		for(d=1;a[d]<i;d++);
		printf("%d",d/(int)pow(10,a[d]-i)%10);
	}
	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