| ||||||||||
| 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 | |||||||||
哪错了,求大神看下,做过#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int i,j,n,c,h,s,p;__int64 a[10],b[10],k,count,rest1,rest2,rest3,t,end;
a[0]=0,b[0]=0;
b[1]=9;
for(i=2;i<=9;i++)
{
b[i]=b[i-1]+9*pow(10.0,i-1)*i;
}
a[1]=45;
for(i=2;i<=9;i++)
{
a[i]=(b[i-1]+i+b[i])*9*pow(10.0,i-1)/2;
}
cin>>n;
for(p=1;p<=n;p++)
{
cin>>k;
count=0;
for(i=0;k>count;)
{
i++;
count+=a[i];
}
count=count-a[i];
rest1=k-count;
count=0;
for(j=0;rest1>count;)
{
j++;
count+=(b[i-1]+i*j);
}
count=count-b[i-1]-i*j;
rest2=rest1-count;
count=0;
for(i=0;rest2>b[i];)
{
i++;
}
rest3=rest2-b[i-1];
t=rest3/i;
s=rest3%i;
end=pow(10.0,i-1)-1+t;
if(s!=0)
{
end++;
for(j=1;j<=s;j++)
{
c=pow(10.0,i-j);
h=end/c;
end=end%10;
}
}
if(s==0)
{
h=end%10;
}
cout<<h<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator