結果

問題 No.1006 Share an Integer
ユーザー mkawa2mkawa2
提出日時 2020-03-06 22:51:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 426 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 82,704 KB
実行使用メモリ 91,940 KB
最終ジャッジ日時 2024-04-22 10:03:15
合計ジャッジ時間 5,280 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,100 KB
testcase_01 AC 39 ms
52,216 KB
testcase_02 AC 47 ms
57,608 KB
testcase_03 AC 41 ms
52,960 KB
testcase_04 AC 49 ms
60,304 KB
testcase_05 AC 54 ms
60,252 KB
testcase_06 AC 50 ms
59,624 KB
testcase_07 AC 48 ms
60,164 KB
testcase_08 AC 48 ms
60,316 KB
testcase_09 AC 47 ms
60,784 KB
testcase_10 AC 47 ms
60,908 KB
testcase_11 AC 197 ms
84,232 KB
testcase_12 AC 352 ms
90,608 KB
testcase_13 AC 400 ms
91,824 KB
testcase_14 AC 381 ms
91,620 KB
testcase_15 AC 338 ms
89,348 KB
testcase_16 AC 145 ms
82,328 KB
testcase_17 AC 179 ms
84,572 KB
testcase_18 AC 314 ms
89,364 KB
testcase_19 AC 288 ms
88,784 KB
testcase_20 AC 329 ms
89,588 KB
testcase_21 AC 426 ms
91,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def II(): return int(sys.stdin.readline())

def main():
    def score(a):
        b=x-a
        sa=a-cntf[a]
        sb=b-cntf[b]
        return abs(sa-sb)

    x=II()
    cntf=[2]*(x+1)
    cntf[1]=1
    for b in range(2,x):
        if b*2>x:break
        for a in range(2*b,x+1,b):
            cntf[a]+=1
    mn=10**9
    ans=[]
    for a in range(1,x+1):
        s=score(a)
        if s==mn:ans.append((a,x-a))
        if s<mn:
            mn=s
            ans=[(a,x-a)]
    for a in ans:print(*a)

main()
0