結果
| 問題 | No.3651 K-th Sum of Divisors |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2026-08-29 15:14:42 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 897 bytes |
| 記録 | |
| コンパイル時間 | 200 ms |
| コンパイル使用メモリ | 52,736 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2026-08-29 15:14:45 |
| 合計ジャッジ時間 | 2,498 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 30 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 3651.cc: No.3651 K-th Sum of Divisors - yukicoder
*/
#include<cstdio>
#include<algorithm>
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 && (l == 0 || bs[n] < 0)) {
if (n < MOD) bs[n] = l;
n = as[l++] = 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;
}
tnakao0123