How many days?
Time limit:3000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 6194 Accepted Submission (s): 3624
Problem Description8600 's mobile phone consumption of 1 yuan per day, each consumption of K yuan can be donated 1 yuan, a start 8600 has m yuan, how many days can I ask?
Input inputs include multiple test instances. Each test instance consists of 2 integers M, K, (2 <= k <= M <= 1000). M = 0, k = 0 indicates the end of the input.
Output outputs an integer for each test instance that represents the number of days that the M-element can be used.
Sample Input
2 24 30 0
Sample Output
35
Author8600
Sourcehdu 2006-12 Programming Contes bored, study day by day until the money is 0.
#include <iostream>using namespace Std;int main () {int M,k;while (cin>>m>>k,m+k) {int day=0,count=0; while (m) {day++;count++;m--;if (count==k) {m++;count=0;}} Cout<<day<<endl;} return 0;}
Hangzhou Electric HDU ACM 1555 How is many days?