結果

問題 No.1006 Share an Integer
ユーザー nanigasi_3
提出日時 2020-03-06 21:42:09
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 640 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 81,792 KB
最終ジャッジ日時 2024-10-14 04:50:31
合計ジャッジ時間 4,315 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 TLE * 1 -- * 10
権限があれば一括ダウンロードができます

ソースコード

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