結果
問題 | No.1006 Share an Integer |
ユーザー |
|
提出日時 | 2020-09-09 15:31:38 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,061 bytes |
コンパイル時間 | 408 ms |
コンパイル使用メモリ | 82,348 KB |
実行使用メモリ | 93,584 KB |
最終ジャッジ日時 | 2024-12-15 06:51:54 |
合計ジャッジ時間 | 20,211 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 TLE * 2 |
ソースコード
from collections import defaultdict def Sieve_of_Eratosthenes(maxA): lst = [-1]*(maxA+1) lst[0] = 0 lst[1] = 1 for i in range(2, maxA+1): if lst[i] == -1: for g in range(i, maxA+1, i): if lst[g] == -1: lst[g] = i return lst def factorization(n): # 「n = 1」はダメ!!! d = defaultdict(int) now = n while True: if now == lst[now]: if now != 1: d[now] += 1 break r = lst[now] while now % r == 0: now //= r d[r] += 1 ans = 1 for i, m in d.items(): ans *= (m+1) return ans x = int(input()) lst = Sieve_of_Eratosthenes(x) MIN = float("inf") ans_list = [] for i in range(1, x): a = i b = x-i fa = a-factorization(a) fb = b-factorization(b) dif = abs(fa-fb) if MIN > dif: MIN = dif ans_list = [] ans_list.append((a, b)) elif MIN == dif: ans_list.append((a, b)) for a, b in ans_list: print(a, b)