fork download
  1. #include<stdio.h>
  2. #include<string.h>
  3. char S[33];
  4. long long Q;
  5. char f(long long n, long long x) {
  6. if (n == Q)return x;
  7. long long nn = n / 2;
  8. if (x < nn)return f(nn, x);
  9. else return f(nn, (x - nn - 1) < 0 ? (x - nn - 1) + nn : (x - nn - 1));
  10. }
  11. int main() {
  12. long long n, m;
  13. scanf("%s%lld", &S, &n);
  14. n--;
  15. Q = m = strlen(S);
  16. while (m <= n)
  17. m *= 2;
  18. printf("%c",S[f(m, n)]);
  19. return 0;
  20. }
Success #stdin #stdout 0s 4516KB
stdin
Standard input is empty
stdout