結果

問題 No.1006 Share an Integer
ユーザー NoviNovi
提出日時 2020-05-07 02:27:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 561 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 12,236 KB
最終ジャッジ日時 2023-09-16 07:39:22
合計ジャッジ時間 3,962 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,236 KB
testcase_01 AC 16 ms
7,884 KB
testcase_02 AC 17 ms
7,836 KB
testcase_03 AC 15 ms
7,900 KB
testcase_04 AC 18 ms
7,796 KB
testcase_05 AC 21 ms
7,904 KB
testcase_06 AC 22 ms
7,912 KB
testcase_07 AC 25 ms
7,788 KB
testcase_08 AC 21 ms
7,832 KB
testcase_09 AC 25 ms
7,960 KB
testcase_10 AC 23 ms
7,884 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=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(1,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