| ||||||||||
| 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 | |||||||||
为什么会Runtime Error?数据都行.#include <iostream>
#include <math.h>
using namespace std;
int b1[100000];
int b2[10000000];
void setb1(int b1[],int n)
{
int i,first1,first2,count1=0;
b1[0]=0;
for(i=1;i<n;i++)
{
if(i==pow(double(10),count1))
{
if(i==0)
{
first1=0;
first2=0;
}
else
{
first1=b1[i-1];
first2=i-1;
}
count1++;
}
b1[i]=first1+count1*(i-first2);
}
}
void setb2(int b2[],int n)
{
int i;
b2[0]=0;
for(i=1;i<n;i++)
{
b2[i]=b2[i-1]+b1[i];
}
}
int main()
{
int i,j,n,m;
setb1(b1,100000);
setb2(b2,10000000);
cin>>n;
for(i=0;i<n;i++)
{
cin>>m;
for(j=0;;j++)
{
if(m>b2[j] && m<=b2[j+1])
{
m-=b2[j];
break;
}
}
for(j=0;;j++)
{
if(m>b1[j] && m<=b1[j+1])
{
m-=b1[j];
break;
}
}
j++;
for(int k=0;k<(b1[j]-b1[j-1]-m);k++)
{
j/=10;
}
cout<<j%10<<endl;
}
return 1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator