結果

問題 No.1006 Share an Integer
ユーザー NoviNovi
提出日時 2020-05-07 11:54:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 621 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 8,676 KB
最終ジャッジ日時 2023-09-16 07:50:58
合計ジャッジ時間 4,672 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,520 KB
testcase_01 AC 17 ms
8,576 KB
testcase_02 AC 16 ms
8,648 KB
testcase_03 RE -
testcase_04 AC 17 ms
8,672 KB
testcase_05 AC 17 ms
8,532 KB
testcase_06 AC 17 ms
8,520 KB
testcase_07 AC 16 ms
8,576 KB
testcase_08 AC 17 ms
8,536 KB
testcase_09 AC 17 ms
8,676 KB
testcase_10 AC 16 ms
8,560 KB
testcase_11 AC 217 ms
8,052 KB
testcase_12 AC 360 ms
8,036 KB
testcase_13 AC 379 ms
8,072 KB
testcase_14 AC 378 ms
7,996 KB
testcase_15 AC 328 ms
8,052 KB
testcase_16 AC 164 ms
8,584 KB
testcase_17 AC 222 ms
8,056 KB
testcase_18 AC 330 ms
8,100 KB
testcase_19 AC 314 ms
8,056 KB
testcase_20 AC 337 ms
8,052 KB
testcase_21 AC 380 ms
8,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
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()
    return divisors

def f(a):
    return a-len(make_divisors(a))
ans=float("inf")
cnt=[]
check=ans
for i in range((x//2)-int(math.sqrt(x))-1,(x//2)+int(math.sqrt(x))+1):
    tmp=abs(f(i)-f(x-i))
    if ans>=tmp:
        cnt.append(i)
        ans=tmp
    check=min(check,tmp)

for i in cnt:
    if abs(f(i)-f(x-i))==check and i>0 and x-i>0:
        print(i,x-i)
0