結果

問題 No.1006 Share an Integer
ユーザー wattaiheiwattaihei
提出日時 2020-03-06 22:20:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 328 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 403 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 85,120 KB
最終ジャッジ日時 2024-04-22 08:39:54
合計ジャッジ時間 4,242 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,352 KB
testcase_01 AC 38 ms
51,584 KB
testcase_02 AC 42 ms
57,728 KB
testcase_03 AC 37 ms
52,224 KB
testcase_04 AC 42 ms
58,240 KB
testcase_05 AC 44 ms
59,264 KB
testcase_06 AC 44 ms
59,392 KB
testcase_07 AC 43 ms
59,104 KB
testcase_08 AC 44 ms
59,392 KB
testcase_09 AC 47 ms
59,008 KB
testcase_10 AC 43 ms
58,960 KB
testcase_11 AC 144 ms
75,264 KB
testcase_12 AC 289 ms
83,072 KB
testcase_13 AC 281 ms
84,096 KB
testcase_14 AC 328 ms
84,096 KB
testcase_15 AC 233 ms
82,304 KB
testcase_16 AC 117 ms
72,320 KB
testcase_17 AC 143 ms
76,032 KB
testcase_18 AC 252 ms
81,280 KB
testcase_19 AC 217 ms
81,280 KB
testcase_20 AC 273 ms
82,432 KB
testcase_21 AC 310 ms
85,120 KB
権限があれば一括ダウンロードができます

ソースコード

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):
    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]))
0