結果

問題 No.338 アンケート機能
ユーザー FromBooskaFromBooska
提出日時 2023-09-21 21:41:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 71,696 KB
最終ジャッジ日時 2023-09-21 21:41:36
合計ジャッジ時間 4,031 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,432 KB
testcase_01 AC 72 ms
71,276 KB
testcase_02 AC 68 ms
71,440 KB
testcase_03 AC 69 ms
71,360 KB
testcase_04 AC 69 ms
71,580 KB
testcase_05 AC 70 ms
71,136 KB
testcase_06 AC 74 ms
71,532 KB
testcase_07 AC 69 ms
71,128 KB
testcase_08 AC 69 ms
71,540 KB
testcase_09 AC 70 ms
71,392 KB
testcase_10 AC 68 ms
71,448 KB
testcase_11 AC 70 ms
71,336 KB
testcase_12 AC 70 ms
71,396 KB
testcase_13 AC 70 ms
71,360 KB
testcase_14 AC 68 ms
71,120 KB
testcase_15 AC 68 ms
71,452 KB
testcase_16 AC 69 ms
71,324 KB
testcase_17 AC 70 ms
71,312 KB
testcase_18 AC 69 ms
71,476 KB
testcase_19 AC 69 ms
71,684 KB
testcase_20 AC 73 ms
71,660 KB
testcase_21 AC 70 ms
71,264 KB
testcase_22 AC 70 ms
71,420 KB
testcase_23 AC 70 ms
71,528 KB
testcase_24 AC 69 ms
71,284 KB
testcase_25 AC 71 ms
71,432 KB
testcase_26 AC 70 ms
71,696 KB
testcase_27 AC 70 ms
71,312 KB
testcase_28 AC 69 ms
71,492 KB
testcase_29 AC 69 ms
71,540 KB
testcase_30 AC 68 ms
71,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 全探索したらACしてしまったが公式解説見る
# 誤差問題なのだと思う
# if A+B==100, a=A, b=Bで解となるのでa, bの上界は100
# if A+B==101, となるのは、AでもBでも+0.5されているということなので
# 四捨五入前は(A-0.5, B-0.5)
# これはa=2*A-1, b=2*B-1で解とできるので、a, bの上界は200
# 100*a/(a+b)=100*(2*A-1)/(202-2)=(2*A-1)/2=A-0.5
# つまり、a, bを200まで全探索すれば解は見つかる

from math import floor, ceil
A, B = map(int, input().split())
for ab in range(1, 400):
    a_lower = ab*(A-0.5)/100
    a_upper = ab*(A+0.5)/100
    for a in range(floor(a_lower), ceil(a_upper)+1):
        b = ab-a
        if b >= 0:
            if (A-0.5)*ab <= 100*a < (A+0.5)*ab:
                if (B-0.5)*ab <= 100*b < (B+0.5)*ab:
                    print(ab)
                    exit()
0