結果

問題 No.1006 Share an Integer
ユーザー FromBooskaFromBooska
提出日時 2023-09-24 08:29:49
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 807 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 87,312 KB
実行使用メモリ 90,040 KB
最終ジャッジ日時 2023-09-24 08:29:55
合計ジャッジ時間 5,449 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,608 KB
testcase_01 AC 74 ms
71,648 KB
testcase_02 AC 79 ms
76,324 KB
testcase_03 AC 73 ms
71,652 KB
testcase_04 AC 87 ms
75,968 KB
testcase_05 AC 88 ms
76,540 KB
testcase_06 AC 86 ms
76,632 KB
testcase_07 AC 87 ms
76,488 KB
testcase_08 AC 86 ms
76,408 KB
testcase_09 AC 89 ms
76,288 KB
testcase_10 AC 89 ms
76,560 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<2*10**6と小さいので全探索して間に合うのでは

X = int(input())
count = [0]*(X+1)

def divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

for x in range(1, X+1):
    calc = len(divisors(x))
    count[x] = calc

ans_list = []
mn = 10**10

for i in range(1, X):
    j = X-i
    calc = abs(i-count[i]-j+count[j])
    #print('i', i, 'j', j, 'calc', calc)
    if calc < mn:
        mn = calc
        ans_list = [(i, j)]
    elif calc == mn:
        ans_list.append((i, j))
        
#print(mn)
#print(ans_list)

for i, j in ans_list:
    print(i, j)









0