0
0

More than 1 year has passed since last update.

paizaラーニング「終了判定 2 Python3編」

Posted at

https://paiza.jp/works/mondai/conditions_branch/conditions_branch__complex_step5
私の回答
whileとbreakを同時に使う必要がなかったようでした。
長い回答にしてしまいました。

n,k=map(int,input().split())
count=0
while (n<=k):
    if n>=k:
        break
    n=n*2
    count=count+1
print(count)

模範回答

n, k = [int(x) for x in input().split()]

m = 0
while n < k:
    n *= 2
    m += 1

print(m)
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