結果

問題 No.1006 Share an Integer
ユーザー FromBooskaFromBooska
提出日時 2023-03-15 21:10:55
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 707 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 81,624 KB
実行使用メモリ 62,024 KB
最終ジャッジ日時 2023-10-18 12:33:00
合計ジャッジ時間 4,790 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,440 KB
testcase_01 AC 36 ms
53,440 KB
testcase_02 AC 43 ms
59,368 KB
testcase_03 AC 37 ms
53,440 KB
testcase_04 AC 43 ms
59,368 KB
testcase_05 AC 49 ms
62,024 KB
testcase_06 AC 48 ms
62,024 KB
testcase_07 AC 49 ms
62,024 KB
testcase_08 AC 47 ms
62,024 KB
testcase_09 AC 51 ms
62,024 KB
testcase_10 AC 49 ms
62,024 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までの約数全列挙をしていて間に合うのだろうか

# 約数個数def
def divisor_count(n):
    count = 0
    i = 1
    while i*i <= n:
        if n % i == 0:
            count += 1
            if i != n // i:
                count += 1
        i += 1
    return count

X = int(input())
div_count = [0]*(X+1)
for i in range(1, X+1):
    div_count[i] = divisor_count(i)

mn = 10**10
mn_list = []
for a in range(1, X):
    b = X - a
    calc = abs(a - div_count[a] - b + div_count[b])
    if calc < mn:
        mn = calc
        mn_list = []
        mn_list.append((a, b))
    elif calc == mn:
        mn_list.append((a, b))
        
#print(mn_list)

for a, b in mn_list:
    print(a, b)


0