結果

問題 No.1006 Share an Integer
ユーザー ttrttr
提出日時 2020-03-06 22:36:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 63,440 KB
最終ジャッジ日時 2024-04-22 09:42:25
合計ジャッジ時間 2,903 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,688 KB
testcase_01 AC 38 ms
53,076 KB
testcase_02 AC 48 ms
63,096 KB
testcase_03 AC 36 ms
52,680 KB
testcase_04 AC 50 ms
63,440 KB
testcase_05 AC 58 ms
62,848 KB
testcase_06 AC 54 ms
63,232 KB
testcase_07 AC 55 ms
63,104 KB
testcase_08 AC 56 ms
63,360 KB
testcase_09 AC 55 ms
63,232 KB
testcase_10 AC 54 ms
63,104 KB
testcase_11 AC 94 ms
63,232 KB
testcase_12 AC 111 ms
62,976 KB
testcase_13 AC 111 ms
63,232 KB
testcase_14 AC 111 ms
62,976 KB
testcase_15 AC 106 ms
63,360 KB
testcase_16 AC 93 ms
63,104 KB
testcase_17 AC 96 ms
62,976 KB
testcase_18 AC 102 ms
63,360 KB
testcase_19 AC 102 ms
63,360 KB
testcase_20 AC 105 ms
63,360 KB
testcase_21 AC 109 ms
63,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

X = int(input())

def f(n):
    cnt = 0
    i = 2
    while i < n**0.5:
        if n%i == 0:
            cnt += 2
        i += 1
    if n**0.5 == int(n**0.5):
        cnt += 1
    return n-cnt

m = X+1
i = 0
while i < 300 and X//2-i > 0:
    m = min(m, abs(f(X//2-i)-f(X-X//2+i)))
    i += 1

L = []
i = 0
while i < 300 and X//2-i > 0:
    if m == abs(f(X//2-i)-f(X-X//2+i)):
        L.append((X//2-i, X-X//2+i))
        L.append((X-X//2+i, X//2-i))
    i += 1

if X%2 == 0:
    L.remove((X//2, X//2))
L.sort()
for l in L:
    print(l[0], l[1])
0