fork download
  1. #include<bits/stdc++.h>
  2. #define f1(i, n) for(ll i=1;i<=n;++i)
  3. #define f0(i, n) for(ll i=0;i<n;++i)
  4. #define ull unsigned long long
  5. #define ll long long
  6. #define rev(a) reverse(a.begin(),a.end())
  7. #define all(x) x.begin(),x.end()
  8. #define so(A, n) sort(A+1, A+n+1)
  9. using namespace std;
  10. const int maxn = 2e5 + 1;
  11. // ll A[maxn];
  12. int main()
  13. {
  14. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  15. string s;
  16. int n, pos;
  17. cin >> s >> n >> pos;
  18. int cnt = 0;
  19. for (int i = 0; i < s.size() && cnt < pos; ++i) {
  20. if (s[i] == '1') {
  21. cnt++;
  22. }
  23. else {
  24. int luythua = 1, motcaigiday = s[i] - 48;
  25. while (cnt + motcaigiday < pos && luythua <= n) {
  26. motcaigiday = pow(s[i] - 48, luythua);
  27. ++luythua;
  28. }
  29. if (cnt + motcaigiday >= pos) {
  30. cout << s[i];
  31. return 0;
  32. }
  33. else {
  34. cnt += motcaigiday;
  35. }
  36. }
  37. }
  38.  
  39.  
  40. return 0;
  41. }
  42.  
  43.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty