0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ABC158 C - Tax Increase から学んだ

Posted at

abc158c_1.png
abc158c_2.png
abc158c_3.png

油断したつもりはなかったが WA

abc158c_ng.py
A,B = map(int,input().split())
from math import floor
for x in range(1,101): #<= ここ
    if floor(x*0.08) == A and floor(x*0.1) == B:
        print(x)
        exit()
print(-1)

敗因はコメントにあるここ
A,B は max 100 .つまり 答えの数値を 1/100 して 100 なわけだから 100 の 100 倍は最低でも覚悟しないとダメ。
一応、多めに for は回してみた。

abc158c_ok.py
A,B = map(int,input().split())
from math import floor
for x in range(1,10**5+1):
    if floor(x*0.08) == A and floor(x*0.1) == B:
        print(x)
        exit()
print(-1)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?