結果

問題 No.1006 Share an Integer
ユーザー ttr
提出日時 2020-03-06 22:36:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 64,128 KB
最終ジャッジ日時 2024-10-14 08:55:54
合計ジャッジ時間 2,877 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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