(HDU)1555-- How many days? (多少天)

题目链接:https://vjudge.net/problem/HDU-1555

直接模拟,不要用公式,因为数据在变。

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <cmath>
 4 #include <iostream>
 5 #include <algorithm>
 6 #include <string>
 7 #include <cstdlib>
 8 
 9 using namespace std;
10 
11 int main()
12 {
13     int m,k;
14     while(~scanf("%d %d",&m,&k))
15     {
16         if(m==0&&k==0) break;
17         int ans=0,loop=0;
18         while(m)
19         {
20             m--; loop++;
21             if(loop==k) m++,loop=0;
22             ans++;
23         }
24         printf("%d\n",ans);
25     }
26     return 0;
27 }

 

posted @ 2016-12-07 16:04  ACDoge  阅读(343)  评论(0编辑  收藏  举报