| ||||||||||
| 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 | |||||||||
无需用long int足以解决 贴0MS代码#include <iostream>
using namespace std;
int data[32005];
int main()
{
int c=1,w=1;
for(int i=1;i<32005;i++)
{
data[i]=c;
if(i==9||i==99||i==999||i==9999)
w++;
c+=w;
}
int t;
cin>>t;
for(int i=0;i<t;i++)
{
int a,c=1;
cin>>a;
while(a-data[c]>0)
{
a-=data[c];
c++;
}
//cout<<"第"<<c<<"区间"<<endl;
w=1;
int j;
for(j=1;j<=c;j++)
{
if(a-w<=0)
break;
a-=w;
if(j==9||j==99||j==999||j==9999)
w++;
}
//cout<<"第"<<j<<"个数"<<endl;
char t[256];
string s;
sprintf(t,"%d",j);
s = t;
cout<<s[a-1]<<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