結果

問題 No.1006 Share an Integer
ユーザー tamatotamato
提出日時 2020-03-06 21:37:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 362 ms / 2,000 ms
コード長 604 bytes
コンパイル時間 422 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 91,644 KB
最終ジャッジ日時 2024-04-22 05:23:24
合計ジャッジ時間 4,802 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,004 KB
testcase_01 AC 37 ms
52,520 KB
testcase_02 AC 45 ms
59,800 KB
testcase_03 AC 38 ms
52,528 KB
testcase_04 AC 42 ms
59,620 KB
testcase_05 AC 42 ms
60,312 KB
testcase_06 AC 42 ms
60,164 KB
testcase_07 AC 41 ms
59,432 KB
testcase_08 AC 41 ms
60,184 KB
testcase_09 AC 41 ms
59,404 KB
testcase_10 AC 42 ms
59,292 KB
testcase_11 AC 150 ms
84,564 KB
testcase_12 AC 290 ms
90,312 KB
testcase_13 AC 294 ms
91,644 KB
testcase_14 AC 362 ms
91,112 KB
testcase_15 AC 253 ms
88,876 KB
testcase_16 AC 122 ms
82,080 KB
testcase_17 AC 153 ms
84,780 KB
testcase_18 AC 268 ms
89,176 KB
testcase_19 AC 254 ms
89,136 KB
testcase_20 AC 255 ms
89,688 KB
testcase_21 AC 343 ms
91,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.readline

    X = int(input())

    num_d = list(range(X+1))
    for d in range(1, X+1):
        for j in range(1, (X // d) + 1):
            num_d[d*j] -= 1

    diff = 10**8
    ans = []
    for a in range(1, (X//2)+1):
        tmp = abs(num_d[a] - num_d[X-a])
        if tmp < diff:
            ans = [a]
            diff = tmp
        elif tmp == diff:
            ans.append(a)
    for a in ans:
        print(a, X-a)
    if ans[-1]*2 == X:
        ans.pop()
    for a in reversed(ans):
        print(X-a, a)



if __name__ == '__main__':
    main()
0