結果

問題 No.1006 Share an Integer
ユーザー brthyyjpbrthyyjp
提出日時 2020-03-06 23:13:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 71,148 KB
最終ジャッジ日時 2024-04-22 10:27:35
合計ジャッジ時間 2,578 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,352 KB
testcase_01 AC 37 ms
52,480 KB
testcase_02 AC 46 ms
59,520 KB
testcase_03 AC 39 ms
52,096 KB
testcase_04 AC 47 ms
60,416 KB
testcase_05 AC 50 ms
61,440 KB
testcase_06 AC 50 ms
61,568 KB
testcase_07 AC 50 ms
61,824 KB
testcase_08 AC 48 ms
61,184 KB
testcase_09 AC 51 ms
61,824 KB
testcase_10 AC 50 ms
61,568 KB
testcase_11 AC 73 ms
67,712 KB
testcase_12 AC 77 ms
70,784 KB
testcase_13 AC 78 ms
71,148 KB
testcase_14 AC 78 ms
71,040 KB
testcase_15 AC 77 ms
69,888 KB
testcase_16 AC 69 ms
66,560 KB
testcase_17 AC 71 ms
67,712 KB
testcase_18 AC 78 ms
70,272 KB
testcase_19 AC 77 ms
69,760 KB
testcase_20 AC 78 ms
70,272 KB
testcase_21 AC 80 ms
70,912 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