MiYu原创, 转帖请注明 : 转载自 ______________白白の屋    

 

题目地址:

      http://acm.hdu.edu.cn/showproblem.php?pid=1555 

题目描述:

How many days?

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1650    Accepted Submission(s): 997


Problem Description
8600的手机每天消费1元,每消费K元就可以获赠1元,一开始8600有M元,问最多可以用多少天?
 

Input
输入包括多个测试实例.每个测试实例包括2个整数M, k,(2 <= k <= M <= 1000).M = 0, k = 0代表输入结束.
 

Output
对于每个测试实例输出一个整数,表示M元可以用的天数。
 

Sample Input
2 2 4 3 0 0
 

Sample Output
3 5
 

Author
8600
 

好水 的题啊 ......      

 

代码
/*
MiYu原创, 转帖请注明 : 转载自 ______________白白の屋
          
http://www.cnblog.com/MiYu
Author By : MiYu
Test      : 1
Program   : 1555
*/

#include 
<iostream>
using namespace std;
int main ()
{
    
int M,K;
    
while ( cin >> M >> K && M | K )
    {
          
int tag = 0,day = 0;;
          
while ( M -- )
          {
                tag 
++;
                day 
++;
                
if ( tag == K )
                {
                     M 
++;
                     tag 
= 0
                } 
          } 
          cout 
<< day << endl;
    }
    
return 0;
}

 

 

 

 

 posted on 2010-08-26 18:56  MiYu  阅读(478)  评论(0编辑  收藏  举报