結果

問題 No.928 軽減税率?
ユーザー simansiman
提出日時 2023-04-18 23:17:06
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 391 bytes
コンパイル時間 32 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-04-22 00:39:19
合計ジャッジ時間 5,319 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
12,416 KB
testcase_01 AC 143 ms
12,288 KB
testcase_02 AC 79 ms
12,288 KB
testcase_03 AC 77 ms
12,160 KB
testcase_04 AC 148 ms
12,160 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 146 ms
12,160 KB
testcase_08 AC 147 ms
12,416 KB
testcase_09 WA -
testcase_10 AC 145 ms
12,416 KB
testcase_11 AC 147 ms
12,288 KB
testcase_12 WA -
testcase_13 AC 137 ms
12,288 KB
testcase_14 AC 147 ms
12,416 KB
testcase_15 WA -
testcase_16 AC 148 ms
12,288 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 76 ms
12,288 KB
testcase_23 AC 76 ms
12,032 KB
testcase_24 AC 77 ms
12,160 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 77 ms
12,032 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

P, Q, A = gets.split.map(&:to_i)

def f(x)
  (x + Rational(P * x, 100).floor) < (x + Rational(Q * x, 100).floor) + A
end

if f(1)
  ok = 1
  ng = 10 ** 9 + 1

  while (ok - ng).abs >= 2
    x = (ok + ng) / 2

    if f(x)
      ok = x
    else
      ng = x
    end
  end

  ans = ok
  (ok + 1).upto([ok + 100_000, 10 ** 9].min) do |x|
    ans += 1 if f(x)
  end

  puts ans
else
  puts 0
end
0