fzu 1150 Farmer Bill's Problem

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

int main()
{
    int n,m,k,ans;
    while(~scanf("%d%d",&n,&k))
    {
        ans=0;
        m=0;
        ans=n;
        m=n;
        while(n>=k)
        {
            m=n/k;
            ans+=n/k;
            n=n%k;
            n+=m;
        }
        printf("%d\n",ans);
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/

posted @ 2015-08-08 11:48  xryz  阅读(150)  评论(0编辑  收藏  举报