結果
問題 | No.1006 Share an Integer |
ユーザー | 双六 |
提出日時 | 2020-08-06 15:35:50 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,549 bytes |
コンパイル時間 | 251 ms |
コンパイル使用メモリ | 81,840 KB |
実行使用メモリ | 96,692 KB |
最終ジャッジ日時 | 2023-10-19 22:24:17 |
合計ジャッジ時間 | 21,013 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 232 ms
90,228 KB |
testcase_01 | AC | 292 ms
90,228 KB |
testcase_02 | TLE | - |
testcase_03 | AC | 138 ms
90,236 KB |
testcase_04 | AC | 922 ms
92,488 KB |
testcase_05 | AC | 925 ms
92,488 KB |
testcase_06 | AC | 921 ms
92,488 KB |
testcase_07 | AC | 918 ms
92,488 KB |
testcase_08 | AC | 939 ms
94,552 KB |
testcase_09 | AC | 934 ms
92,488 KB |
testcase_10 | AC | 933 ms
94,620 KB |
testcase_11 | AC | 930 ms
92,488 KB |
testcase_12 | AC | 928 ms
92,488 KB |
testcase_13 | AC | 918 ms
92,488 KB |
testcase_14 | AC | 933 ms
94,632 KB |
testcase_15 | AC | 945 ms
92,488 KB |
testcase_16 | AC | 930 ms
92,488 KB |
testcase_17 | AC | 935 ms
92,488 KB |
testcase_18 | AC | 931 ms
92,488 KB |
testcase_19 | AC | 923 ms
92,488 KB |
testcase_20 | AC | 924 ms
92,488 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()