| ||||||||||
| 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 | |||||||||
poj 1019求教一下 为什么 time run error 附上代码#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator