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 |
why WA!!#include<iostream> using namespace std; int main() { int t; int num[4]={45,9000,1386450,188019000}; int dig[4]={1,11,192,2893}; int dig2[5]={9,180,2700,36000,450000}; cin>>t; //t=1; while(t--) { long int n;//=t; cin>>n; int i; for(i=0;i<=3&&n-num[i]>0;i++) { n-=num[i]; } i++; int d=dig[i-1]; while(n-d>0) { n-=d; d+=i; }//now the answer is the nth digit of the number sequence 123456789101112... int a; for(a=0;n-dig2[a]>0;a++) { n-=dig2[a]; } a++; //now the answer is the nth number of the number sequence (10^(a-1) 10^(a-1)+1 10^(a-1)+2 ...) int b=(n+a-1)%a; int c=(n+a-1)/a; //now the answer is the bth number of the number 10^(a-1)+c-1 int num=1; for(int p=0;p<a-1;p++) { num*=10; } num+=(c-1); for(int q=0;q<a-b-1;q++) { num/=10; } cout<<(num-num/10*10)<<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