how many times?


Submit solution

Points: 35 (partial)
Time limit: 1.1s
Memory limit: 256M

Authors:
Problem type
Allowed languages
Java 19, Java 8

題目說明

請設計一個程式,其中僅有加減法,使用者可輸入一目標數與基數,在輸入一個符號

最後輸出需要加或減基數幾次才能達到目標數,若無法達到則輸出0

輸入限制 整數,其中基數必不為0

輸入

目標數,基數,加減符號(擇一)

輸出

基數需要加或減基數幾次,若無法達到則輸出0

測試資料0 輸入

3 1 +

測試資料0 輸出

2

1 + 1 + 1 = 3: 加兩次,所以輸出2

測試資料1 輸入

4 2 -

測試資料1 輸出

0

2 - 2 - 2 - 2 - ...永遠不會等於4,所以輸出0


Comments

There are no comments at the moment.