結果

問題 No.1006 Share an Integer
ユーザー s_shoheis_shohei
提出日時 2020-04-11 15:02:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 1,011 ms
コンパイル使用メモリ 81,432 KB
実行使用メモリ 77,300 KB
最終ジャッジ日時 2023-10-19 06:11:14
合計ジャッジ時間 5,073 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,676 KB
testcase_01 AC 46 ms
55,676 KB
testcase_02 AC 62 ms
66,264 KB
testcase_03 AC 46 ms
55,496 KB
testcase_04 AC 60 ms
68,312 KB
testcase_05 AC 72 ms
72,756 KB
testcase_06 AC 72 ms
72,756 KB
testcase_07 AC 73 ms
73,032 KB
testcase_08 AC 70 ms
72,756 KB
testcase_09 AC 73 ms
73,120 KB
testcase_10 AC 71 ms
72,756 KB
testcase_11 AC 201 ms
77,292 KB
testcase_12 AC 231 ms
77,292 KB
testcase_13 AC 236 ms
77,300 KB
testcase_14 AC 235 ms
77,292 KB
testcase_15 AC 225 ms
77,292 KB
testcase_16 AC 189 ms
77,288 KB
testcase_17 AC 204 ms
77,296 KB
testcase_18 AC 227 ms
77,296 KB
testcase_19 AC 224 ms
77,296 KB
testcase_20 AC 230 ms
77,296 KB
testcase_21 AC 235 ms
77,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

x=int(input())

def m_div(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)
    return divisors

from functools import lru_cache
@lru_cache(maxsize=None)
def f(num):
    return num - len(m_div(num))

mn = float("inf")
s=max(1,(x//2)-5000)
e=min(x,(x//2) +5000)
for a in range(s,e):
    b=x-a
    mn=min(mn,abs(f(a)-f(b)))

for a in range(s,e):
    b=x-a
    if abs(f(a)-f(b))==mn:
        print(a,b)
0