結果
問題 | No.1006 Share an Integer |
ユーザー |
|
提出日時 | 2020-09-09 15:38:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 975 ms / 2,000 ms |
コード長 | 1,107 bytes |
コンパイル時間 | 472 ms |
コンパイル使用メモリ | 82,828 KB |
実行使用メモリ | 93,164 KB |
最終ジャッジ日時 | 2024-12-15 06:58:28 |
合計ジャッジ時間 | 10,427 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
from collections import defaultdictdef Sieve_of_Eratosthenes(maxA):lst = [-1]*(maxA+1)lst[0] = 0lst[1] = 1for i in range(2, maxA+1):if lst[i] == -1:for g in range(i, maxA+1, i):if lst[g] == -1:lst[g] = ireturn lstdef factorization(n):d = defaultdict(int)now = nwhile True:if now == lst[now]:if now != 1:d[now] += 1breakr = lst[now]while now % r == 0:now //= rd[r] += 1ans = 1for i, m in d.items():ans *= (m+1)return ansx = int(input())lst = Sieve_of_Eratosthenes(x)MIN = float("inf")ans_list = []for i in range(1, x//2+1):a = ib = x-ifa = a-factorization(a)fb = b-factorization(b)dif = abs(fa-fb)if MIN > dif:MIN = difans_list = []ans_list.append((a, b))elif MIN == dif:ans_list.append((a, b))for a, b in ans_list:if a == b:breakprint(a, b)for a, b in ans_list[::-1]:print(b, a)