Codeforces 1216E1. Numerical Sequence (easy version) Solution

Solve in       C++:

///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE
///Islamic University,Bangladesh
  1. #include<iostream>
  2. #include<string>
  3. using namespace std;
  4. int main()
  5. {
  6. long long t;
  7. cin>>t;
  8. while(t--)
  9. {
  10. long long n,v=0;
  11. cin>>n;
  12. string s;
  13. while(1)
  14. {
  15. v++;
  16. string s1 = to_string(v);
  17. s+=s1;
  18. if(n>s.length())
  19. n-=s.length();
  20. else
  21. {
  22. cout << s[n-1]<<endl;
  23. break;
  24. }
  25.  
  26. }
  27.  
  28. }
  29.  
  30. return 0;
  31. }

No comments

Most View Post

Recent post

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.