LoginSignup
0
0

More than 1 year has passed since last update.

ABC83 C - Multiple Gift を解いた

Last updated at Posted at 2021-09-25

abc83_1.png
abc83_2.png
abc83_3.png
abc83_4.png
abc83_5.png

数列を長くするのであれば、Ai+1,Ai の倍数はなるべく小さい方がいい。2 じゃね?
とりあえず、2 倍で数列を作って、配列長を答えとしてみる。

MultipleGift.py
x,y = map(int,input().split())

lis = [x]

for i in range(1,10001):
    if lis[i-1]*2 <= y:
        lis.append(lis[i-1]*2)
    else:
        break

print(len(lis))

以下の記述の方がイメージしやすいし、
読みやすいかも。

abc83c.py
X,Y = map(int,input().split())

lis = [X]

while True:
    if X*2 <= Y:
        X = 2*X
        lis.append(X)
        if X == Y:
            break
    else:
        break
print(len(lis))
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