結果
問題 |
No.1006 Share an Integer
|
ユーザー |
|
提出日時 | 2020-04-16 16:49:29 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 929 bytes |
コンパイル時間 | 284 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 17,824 KB |
最終ジャッジ日時 | 2024-10-01 20:14:46 |
合計ジャッジ時間 | 4,241 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 WA * 4 TLE * 1 -- * 10 |
ソースコード
import math def f(x): temp = x count_dict = {} while True: if x == 1: break for i in range(2, x+1): if x % i == 0: if i not in count_dict: count_dict[i] = 1 else: count_dict[i] += 1 x //= i break count = 1 for i in count_dict.values(): count *= (i+1) return temp-count def difference(x, y): return abs(f(x)-f(y)) X = int(input()) temp_dict = {} for i in range(1, X//2+1): if abs(i-(X-i)) <= 2*(2*math.sqrt(X)+1): diff = difference(i, X-i) if diff not in temp_dict: temp_dict[diff] = [[i, X-i]] else: temp_dict[diff].append([i, X-i]) min_key = min(temp_dict.keys()) for data in temp_dict[min_key]: print(data[0], data[1]) for data in temp_dict[min_key][::-1]: print(data[1], data[0])