0
0

More than 1 year has passed since last update.

paizaラーニング「N が M ずつ増えたときにいつ K を越える? Python3編」

Posted at

私の解答

n,m,k = map(int,input().split())
ans = 0
if n <= k:
    while n + m <= k:
        n = n + m
        ans += 1
    print(ans+1)
else:
    print(0)

私の解答は長すぎでした。

解答例

N, M, K = map(int, input().split())
num = 0
while N <= K:
    N += M
    num += 1

print(num)
0
0
1

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