Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <cstring>
- #include <fstream>
- using namespace std;
- string int_to_string(int x) {
- string s = "";
- while(x > 0) {
- s += (x % 10) + '0';
- x /= 10;
- }
- reverse(s.begin(), s.end());
- return s;
- }
- int main() {
- int n;
- cin >> n;
- string s = "";
- int vkupna_golemina = 0;
- int cnt = 1;
- while(vkupna_golemina < n) {
- s += int_to_string(cnt);
- vkupna_golemina += (int) s.size();
- cnt++;
- }
- int region = vkupna_golemina - (int) s.size();
- // cout << vkupna_golemina <<" " << (int) s.size() << endl;
- int idx = 0;
- while(region < n) {
- region++;
- idx++;
- }
- cout << s[idx - 1] << endl;
- return 0;
- }
- // 1 12 123 1234 12345
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement