HDU 1555 How many days?

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

模拟一下就行了..注意不要忘了m<k时的处理

#include <iostream>

using namespace std;

int main()
{
    int m,k;
    int ans;
    while(cin>>m>>k&&m+k!=0)
    {
        ans=0;

        while(m!=0)
        {
            if(m>=k)
            {
                ans+=k;
                m-=k;
                m+=1;
            }
            else
            {
                ans+=m;
                m=0;
            }


        }
        cout<<ans<<endl;

    }
    return 0;
}


 

原文地址:https://www.cnblogs.com/frankM/p/4399507.html