結果
問題 | No.1006 Share an Integer |
ユーザー |
|
提出日時 | 2020-09-09 15:34:04 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,102 bytes |
コンパイル時間 | 210 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 41,844 KB |
最終ジャッジ日時 | 2024-12-15 06:54:00 |
合計ジャッジ時間 | 33,495 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 5 WA * 3 TLE * 11 |
ソースコード
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:print(a, b)else:print(a, b)print(b, a)