結果

問題 No.1006 Share an Integer
ユーザー NoviNovi
提出日時 2020-05-07 11:53:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 623 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 8,776 KB
最終ジャッジ日時 2023-09-16 07:50:49
合計ジャッジ時間 4,596 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 17 ms
8,140 KB
testcase_02 AC 17 ms
8,476 KB
testcase_03 RE -
testcase_04 AC 16 ms
8,516 KB
testcase_05 AC 16 ms
8,536 KB
testcase_06 AC 17 ms
8,628 KB
testcase_07 AC 16 ms
8,648 KB
testcase_08 AC 16 ms
8,604 KB
testcase_09 AC 16 ms
8,512 KB
testcase_10 AC 16 ms
8,648 KB
testcase_11 AC 215 ms
8,108 KB
testcase_12 AC 361 ms
8,040 KB
testcase_13 AC 386 ms
8,056 KB
testcase_14 AC 382 ms
8,012 KB
testcase_15 AC 330 ms
7,996 KB
testcase_16 AC 166 ms
8,468 KB
testcase_17 AC 224 ms
8,136 KB
testcase_18 AC 330 ms
8,032 KB
testcase_19 AC 317 ms
8,028 KB
testcase_20 AC 342 ms
7,960 KB
testcase_21 AC 383 ms
8,020 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))-10,(x//2)+int(math.sqrt(x))+10):
    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