結果

問題 No.1006 Share an Integer
ユーザー ryo_nryo_n
提出日時 2020-03-06 22:15:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 858 bytes
コンパイル時間 422 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 123,068 KB
最終ジャッジ日時 2024-04-22 08:20:12
合計ジャッジ時間 4,892 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
61,584 KB
testcase_01 AC 44 ms
55,076 KB
testcase_02 AC 50 ms
61,968 KB
testcase_03 WA -
testcase_04 AC 51 ms
62,416 KB
testcase_05 AC 53 ms
62,908 KB
testcase_06 WA -
testcase_07 AC 54 ms
63,720 KB
testcase_08 AC 52 ms
62,528 KB
testcase_09 AC 55 ms
64,040 KB
testcase_10 AC 54 ms
63,432 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
from functools import lru_cache

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline

@lru_cache(maxsize=None)
def make_len_divisors(n):
    ans = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ans += 1
            if i != n // i:
                ans += 1

    return ans


def main():
    X = int(input())

    mi = float("inf")
    if X % 2 == 0:
        mi = 0
    ans = []
    for i in range(X // 4, X // 2 + 1):
        a = i - make_len_divisors(i)
        b = (X - i) - make_len_divisors(X - i)
        if abs(a - b) < mi:
            mi = abs(a - b)
            ans = []
        if abs(a - b) == mi:
            ans.append([i, X - i])

    for a in ans:
        print(*a)
    for a, b in ans[::-1]:
        if a == b:
            break
        print(b, a)




    

if __name__ == '__main__':
    main()

0