結果

問題 No.1006 Share an Integer
ユーザー nanigasi_3nanigasi_3
提出日時 2020-03-06 21:42:09
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 640 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 81,920 KB
最終ジャッジ日時 2024-04-22 05:37:33
合計ジャッジ時間 4,258 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
57,728 KB
testcase_01 AC 38 ms
52,096 KB
testcase_02 AC 49 ms
60,160 KB
testcase_03 AC 38 ms
51,840 KB
testcase_04 AC 49 ms
60,672 KB
testcase_05 AC 51 ms
61,696 KB
testcase_06 AC 51 ms
61,824 KB
testcase_07 AC 53 ms
62,336 KB
testcase_08 AC 51 ms
61,312 KB
testcase_09 AC 54 ms
62,592 KB
testcase_10 AC 52 ms
61,568 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 #

X = int(input())
ans = set()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors

def calc_cost(a, b):
    return abs((a-len(make_divisors(a)))-(b-len(make_divisors(b))))

min_cost = 10**9
for A in range(1, X//2+1+int(X%2!=0)):
    cost = calc_cost(A, X-A)
    if cost < min_cost:
        min_cost = cost
        ans = set()
    if cost == min_cost:
        ans.add((A, X-A))
        ans.add((X-A, A))
for num in sorted(list(ans)):
    print(*num)
0