結果

問題 No.1006 Share an Integer
ユーザー wattaiheiwattaihei
提出日時 2020-03-06 22:12:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 637 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 61,600 KB
最終ジャッジ日時 2024-04-22 08:07:41
合計ジャッジ時間 4,098 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
17,824 KB
testcase_01 AC 28 ms
10,624 KB
testcase_02 AC 28 ms
10,752 KB
testcase_03 WA -
testcase_04 AC 29 ms
10,624 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 31 ms
10,496 KB
testcase_09 AC 30 ms
10,752 KB
testcase_10 AC 29 ms
10,624 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

X = int(input())
A = [i-1 for i in range(X+1)]
for x in range(2, X+1):
    p = x
    while p <= X:
        A[p] -= 1
        p += x

ans = []
s = 10**13
for x in range(1, X//2+1):
    y = X-x
    score = abs(A[x]-A[y])
    if score < s:
        ans = [(x, y)]
        s = score
    elif score == s:
        ans.append((x, y))

if X%2 == 0:
    x = X//2
    if s != 0:
        ans = [(x, x)]
    elif s == 0:
        ans.append((x, x))
    

print("\n".join([str(a)+" "+str(b) for a, b in ans]))
if ans[-1][0] == ans[-1][1]:
    ans.pop()
print("\n".join([str(b)+" "+str(a) for a, b in ans[::-1]]))
0