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;
}

你可能感兴趣的:(fzu 1150 Farmer Bill's Problem)