Codeforces 1216E1. Numerical Sequence (easy version) Solution
Solve in C++:
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE
///Islamic University,Bangladesh
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE
///Islamic University,Bangladesh
- #include<iostream>
- #include<string>
- using namespace std;
- int main()
- {
- long long t;
- cin>>t;
- while(t--)
- {
- long long n,v=0;
- cin>>n;
- string s;
- while(1)
- {
- v++;
- string s1 = to_string(v);
- s+=s1;
- if(n>s.length())
- n-=s.length();
- else
- {
- cout << s[n-1]<<endl;
- break;
- }
- }
- }
- return 0;
- }
No comments