結果
問題 | No.1006 Share an Integer |
ユーザー | chielo |
提出日時 | 2020-03-06 21:57:58 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 319 ms / 2,000 ms |
コード長 | 782 bytes |
コンパイル時間 | 474 ms |
コンパイル使用メモリ | 87,080 KB |
実行使用メモリ | 129,444 KB |
最終ジャッジ日時 | 2023-08-04 09:49:10 |
合計ジャッジ時間 | 8,357 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 280 ms
129,412 KB |
testcase_01 | AC | 278 ms
129,124 KB |
testcase_02 | AC | 279 ms
129,112 KB |
testcase_03 | AC | 283 ms
129,348 KB |
testcase_04 | AC | 286 ms
129,120 KB |
testcase_05 | AC | 283 ms
129,212 KB |
testcase_06 | AC | 283 ms
129,268 KB |
testcase_07 | AC | 280 ms
129,296 KB |
testcase_08 | AC | 285 ms
129,368 KB |
testcase_09 | AC | 286 ms
129,440 KB |
testcase_10 | AC | 283 ms
129,444 KB |
testcase_11 | AC | 312 ms
129,368 KB |
testcase_12 | AC | 309 ms
129,296 KB |
testcase_13 | AC | 308 ms
129,420 KB |
testcase_14 | AC | 319 ms
129,296 KB |
testcase_15 | AC | 312 ms
129,416 KB |
testcase_16 | AC | 303 ms
129,388 KB |
testcase_17 | AC | 296 ms
129,392 KB |
testcase_18 | AC | 307 ms
129,424 KB |
testcase_19 | AC | 308 ms
129,228 KB |
testcase_20 | AC | 303 ms
129,304 KB |
testcase_21 | AC | 310 ms
129,344 KB |
ソースコード
maxn = 2 * 10 ** 6 + 3 d = [0] * maxn mpc = [0] * maxn p = [] pv = [False] * maxn d[1] = 1 for i in range(2, maxn): if not pv[i]: p.append(i) d[i] = 2 mpc[i] = 1 for j in p: if i * j >= maxn: break if i % j == 0: pv[i * j] = True mpc[i * j] = mpc[i] + 1 d[i * j] = d[i] // mpc[i * j] * (mpc[i * j] + 1) break else: pv[i * j] = True mpc[i * j] = 1 d[i * j] = 2 * d[i] f = lambda n: n - d[n] x = int(input()) ans = 10 ** 18 al = [] for i in range(1, x): a, b = i, x - i c = abs(f(a) - f(b)) if c < ans: ans = c al = [(a, b)] elif c == ans: al.append((a, b)) for a, b in al: print(a, b)