結果

問題 No.1006 Share an Integer
ユーザー rlangevin
提出日時 2023-01-12 08:53:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 396 bytes
コンパイル時間 920 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 91,136 KB
最終ジャッジ日時 2024-12-23 02:22:46
合計ジャッジ時間 6,364 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(x):
    return x - d[x]

X = int(input())
d = [0] * (X + 1)
for i in range(1, X + 1):
    for j in range(i, X + 1, i):
        d[j] += 1

ans = []
pre = 10 ** 18
for i in range(1, X + 1):
    v = abs(f(i) - f(X - i))
    if v > pre:
        continue
    elif v == pre:
        ans.append(i)
    else:
        pre = v
        ans = []
        ans.append(i)

for a in ans:
    print(a, X - a)
0