結果

問題 No.1006 Share an Integer
ユーザー brthyyjpbrthyyjp
提出日時 2020-03-06 23:13:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 87,340 KB
実行使用メモリ 84,780 KB
最終ジャッジ日時 2023-08-04 12:50:27
合計ジャッジ時間 3,398 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,648 KB
testcase_01 AC 70 ms
71,896 KB
testcase_02 AC 77 ms
76,200 KB
testcase_03 AC 66 ms
71,456 KB
testcase_04 AC 76 ms
76,248 KB
testcase_05 AC 81 ms
76,116 KB
testcase_06 AC 79 ms
76,416 KB
testcase_07 AC 81 ms
76,228 KB
testcase_08 AC 80 ms
76,000 KB
testcase_09 AC 80 ms
76,084 KB
testcase_10 AC 79 ms
76,100 KB
testcase_11 AC 100 ms
80,968 KB
testcase_12 AC 105 ms
84,292 KB
testcase_13 AC 105 ms
84,736 KB
testcase_14 AC 104 ms
84,780 KB
testcase_15 AC 102 ms
83,588 KB
testcase_16 AC 96 ms
80,112 KB
testcase_17 AC 99 ms
81,344 KB
testcase_18 AC 103 ms
83,400 KB
testcase_19 AC 105 ms
83,160 KB
testcase_20 AC 107 ms
83,848 KB
testcase_21 AC 106 ms
84,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

x = int(input())

def make_divisors(n):
    divisors = []
    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)

    #divisors.sort(reverse=True)
    return divisors

l = [10**18]* (x//2)
for a in reversed(range(1, x//2+1)):
    b = x - a
    if abs(a-b) >= 1500:
        break
    l[a-1] = abs(a-len(make_divisors(a))-b+len(make_divisors(b)))

#print(l)
min_ = min(l)
anss = []
for i in range(len(l)):
    if l[i] == min_:
        anss.append(i+1)
        if i+1 != x-(i+1):
            anss.append(x-(i+1))
anss.sort()
for i in range(len(anss)):
    print(anss[i], x-anss[i])
0