結果

問題 No.338 アンケート機能
コンテスト
ユーザー はむ吉🐹
提出日時 2016-03-13 20:45:32
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 508 ms / 2,000 ms
+ 203µs
コード長 794 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 55 ms
コンパイル使用メモリ 14,976 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2026-09-21 01:35:41
合計ジャッジ時間 17,872 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import decimal
import itertools


MAX_CAND = 500


def solve(a0, b0):
    answer = None
    with decimal.localcontext() as context:
        context.rounding = decimal.ROUND_HALF_UP
        answer = decimal.Decimal("Inf")
        gen = (context.create_decimal(i) for i in range(MAX_CAND))
        for a, b in itertools.product(gen, repeat=2):
            if a == b == 0:
                continue
            cond_a = context.quantize(100 * a / (a + b), 0) == a0
            cond_b = context.quantize(100 * b / (a + b), 0) == b0
            if cond_a and cond_b:
                answer = min(answer, int(a + b))
    return answer


def main():
    a0, b0 = map(int, input().split())
    print(solve(a0, b0))


if __name__ == '__main__':
    main()
0