結果
問題 | No.1006 Share an Integer |
ユーザー | 双六 |
提出日時 | 2020-08-06 15:38:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,746 ms / 2,000 ms |
コード長 | 1,549 bytes |
コンパイル時間 | 169 ms |
コンパイル使用メモリ | 81,760 KB |
実行使用メモリ | 96,824 KB |
最終ジャッジ日時 | 2023-10-19 22:28:39 |
合計ジャッジ時間 | 34,693 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 214 ms
90,208 KB |
testcase_01 | AC | 286 ms
90,208 KB |
testcase_02 | AC | 1,710 ms
96,644 KB |
testcase_03 | AC | 141 ms
90,208 KB |
testcase_04 | AC | 1,705 ms
96,644 KB |
testcase_05 | AC | 1,723 ms
96,640 KB |
testcase_06 | AC | 1,732 ms
96,572 KB |
testcase_07 | AC | 1,720 ms
96,648 KB |
testcase_08 | AC | 1,722 ms
96,636 KB |
testcase_09 | AC | 1,732 ms
96,644 KB |
testcase_10 | AC | 1,733 ms
96,636 KB |
testcase_11 | AC | 1,735 ms
96,720 KB |
testcase_12 | AC | 1,745 ms
96,744 KB |
testcase_13 | AC | 1,709 ms
96,740 KB |
testcase_14 | AC | 1,721 ms
96,744 KB |
testcase_15 | AC | 1,726 ms
96,744 KB |
testcase_16 | AC | 1,721 ms
96,732 KB |
testcase_17 | AC | 1,731 ms
96,824 KB |
testcase_18 | AC | 1,741 ms
96,732 KB |
testcase_19 | AC | 1,746 ms
96,736 KB |
testcase_20 | AC | 1,730 ms
96,724 KB |
testcase_21 | AC | 1,730 ms
96,744 KB |
ソースコード
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 <= 3 * 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) - 200, int(X // 2) + 200): 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()