implementation *1000

Please click on ads to support us..

Python Code:

import math
from collections import deque
 
 
alfabet = {'a': 1, 'b': 2,'c': 3,'d': 4,'e': 5,'f': 6,'g': 7,'h': 8,'i': 9,'j': 10,'k': 11,'l': 12,'m': 13,'n': 14,'o': 15,'p': 16,'q': 17,'r': 18,'s': 19,'t': 20,'u': 21,'v': 22,'w': 23,'x': 24,'y': 25,'z': 26}

vector=[""]*10001
contor=0
numar=0
while contor<10001:
 numar+=1
 stringul=str(numar)
 stringul=stringul[::-1]

 for i in range(len(stringul)-1,-1,-1):
  contor+=1
  if contor<10001:
   vector[contor]=stringul[i]
  else:
   break
 


 
for i in range(0,1):
  n=int(input())
   
  
 print(vector[n])
  
 
 

  
  
 
 

C++ Code:

#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    ll m,n,a,b;
    cin>>n;
    vector<ll>s,s1;
     for(ll i=1;i<10500;i++)
     {
         ll x=i;
         while(x!=0)
         {
             ll c=x%10;
              s.push_back(c);
              x/=10;
         }
         reverse(s.begin(),s.end());

         for(ll i=0;i<s.size();i++)
            s1.push_back(s[i]);

         s.clear();
     }


    cout<<s1[n-1]<<endl;


}


Comments

Submit
0 Comments
More Questions

443A - Anton and Letters
1478B - Nezzar and Lucky Number
228A - Is your horseshoe on the other hoof
122A - Lucky Division
1611C - Polycarp Recovers the Permutation
432A - Choosing Teams
758A - Holiday Of Equality
1650C - Weight of the System of Nested Segments
1097A - Gennady and a Card Game
248A - Cupboards
1641A - Great Sequence
1537A - Arithmetic Array
1370A - Maximum GCD
149A - Business trip
34A - Reconnaissance 2
59A - Word
462B - Appleman and Card Game
1560C - Infinity Table
1605C - Dominant Character
1399A - Remove Smallest
208A - Dubstep
1581A - CQXYM Count Permutations
337A - Puzzles
495A - Digital Counter
796A - Buying A House
67A - Partial Teacher
116A - Tram
1472B - Fair Division
1281C - Cut and Paste
141A - Amusing Joke