結果

問題 No.1006 Share an Integer
ユーザー FromBooska
提出日時 2023-03-15 21:10:55
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 707 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 81,832 KB
実行使用メモリ 88,776 KB
最終ジャッジ日時 2024-09-18 08:53:24
合計ジャッジ時間 4,503 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 TLE * 1 -- * 10
権限があれば一括ダウンロードができます

ソースコード

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