/* -*- coding: utf-8 -*- * * 3651.cc: No.3651 K-th Sum of Divisors - yukicoder */ #include #include using namespace std; /* constant */ const int MOD = 100003; /* typedef */ using ll = long long; /* global variables */ int as[MOD + 2], bs[MOD]; /* subroutines */ int f(int n) { int sum = 0; for (int p = 1; p * p <= n; p++) if (n % p == 0) { sum += p; int q = n / p; if (q != p) sum += q; } return sum % MOD; } /* main */ int main() { int n; ll k; scanf("%d%lld", &n, &k); k--; fill(bs, bs + MOD, -1); int l = 0; while (l < k && (n >= MOD || bs[n] < 0)) { if (n < MOD) bs[n] = l; as[l++] = n; n = f(n); } //printf(" l=%d, n=%d, bs[%d]=%d\n", l, n, n, bs[n]); int res = n; if (l < k) { int c = l - bs[n]; res = as[bs[n] + (k - bs[n]) % (l - bs[n])]; } printf("%d\n", res); return 0; }