結果

問題 No.1006 Share an Integer
ユーザー yakeshibayakeshiba
提出日時 2020-10-31 21:41:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 746 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 32,112 KB
最終ジャッジ日時 2023-09-29 10:47:16
合計ジャッジ時間 4,448 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,952 KB
testcase_01 AC 17 ms
8,964 KB
testcase_02 AC 19 ms
8,788 KB
testcase_03 AC 17 ms
8,492 KB
testcase_04 AC 20 ms
8,920 KB
testcase_05 AC 23 ms
8,972 KB
testcase_06 AC 23 ms
8,916 KB
testcase_07 AC 24 ms
9,080 KB
testcase_08 AC 21 ms
8,888 KB
testcase_09 AC 23 ms
8,992 KB
testcase_10 AC 24 ms
9,112 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 #

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])

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