結果

問題 No.1006 Share an Integer
ユーザー yakeshibayakeshiba
提出日時 2020-10-31 21:51:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 768 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 87,276 KB
実行使用メモリ 123,068 KB
最終ジャッジ日時 2023-09-29 10:48:01
合計ジャッジ時間 5,618 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_divisors(n):
    from collections import deque
    divisors = deque([])
    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)
    lst_divisors = list(divisors)
    lst_divisors.sort()
    return lst_divisors

X = int(input())

n_div = [0]*(X+1)

d = {}
for a in range(1, X//2+1):
    b = X-a
    n_div[a] = len(make_divisors(a))
    n_div[b] = len(make_divisors(b))
    f = abs((a-n_div[a])-(b-n_div[b]))
    if f not in d:
        d[f] = [[a, b]]
    else:
        d[f].append([a, b])

print(min(d.keys()))

ans = sorted(d[min(d.keys())])
for v in ans:
    a, b = v
    print(a, b)
    
for v in ans[::-1]:
    a, b = v
    if a != b:
        print(b, a)
0