結果
問題 | No.1006 Share an Integer |
ユーザー | 双六 |
提出日時 | 2020-08-06 15:35:50 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,549 bytes |
コンパイル時間 | 201 ms |
コンパイル使用メモリ | 82,184 KB |
実行使用メモリ | 97,252 KB |
最終ジャッジ日時 | 2024-09-19 18:23:56 |
合計ジャッジ時間 | 20,036 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 183 ms
89,600 KB |
testcase_01 | AC | 258 ms
89,728 KB |
testcase_02 | TLE | - |
testcase_03 | AC | 114 ms
89,088 KB |
testcase_04 | AC | 893 ms
92,416 KB |
testcase_05 | AC | 887 ms
91,776 KB |
testcase_06 | AC | 892 ms
92,160 KB |
testcase_07 | AC | 885 ms
91,776 KB |
testcase_08 | AC | 895 ms
93,312 KB |
testcase_09 | AC | 888 ms
91,776 KB |
testcase_10 | AC | 896 ms
93,056 KB |
testcase_11 | AC | 886 ms
92,032 KB |
testcase_12 | AC | 888 ms
91,776 KB |
testcase_13 | AC | 887 ms
92,288 KB |
testcase_14 | AC | 892 ms
93,568 KB |
testcase_15 | AC | 888 ms
92,288 KB |
testcase_16 | AC | 889 ms
92,032 KB |
testcase_17 | AC | 889 ms
92,032 KB |
testcase_18 | AC | 889 ms
92,160 KB |
testcase_19 | AC | 888 ms
92,032 KB |
testcase_20 | AC | 890 ms
92,288 KB |
testcase_21 | WA | - |
ソースコード
import sys; input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") def getlist(): return list(map(int, input().split())) num = 2 * 10 ** 6 + 1 L = [1 for i in range(num)]; L[0] = 0; L[1] = 0 plist = [] for i in range(num): if L[i] == 1: plist.append(i); c = 2 while i * c <= num - 1: L[i * c] = 0; c += 1 def prime_factorization(N): D = defaultdict(int) for i in plist: while N % i == 0: D[i] += 1; N = int(N // i) if N != 1: D[N] += 1 return D #処理内容 def main(): X = int(input()) if X <= 5 * 10 ** 2: L = [] for i in range(1, X): a = i; b = X - i facA = prime_factorization(a) facB = prime_factorization(b) numA = 1; numB = 1 for key, value in facA.items(): numA *= value + 1 for key, value in facB.items(): numB *= value + 1 L.append([abs(a - b - (numA - numB)), a, b]) L.sort() val = L[0][0] for i in range(len(L)): if L[i][0] == val: print(L[i][1], L[i][2]) else: break else: L = [] for i in range(int(X // 2) - 100, int(X // 2) + 100): a = i; b = X - i facA = prime_factorization(a) facB = prime_factorization(b) numA = 1; numB = 1 for key, value in facA.items(): numA *= value + 1 for key, value in facB.items(): numB *= value + 1 L.append([abs(a - b - (numA - numB)), a, b]) L.sort() val = L[0][0] for i in range(len(L)): if L[i][0] == val: print(L[i][1], L[i][2]) else: break if __name__ == '__main__': main()