P1150 Peter的烟【递归】

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll s,sum,n,k;
void smoke(ll i)
{
    if(i>=k)
    {
        s=s+floor(i/k);
        smoke(floor(i/k)+i%k);
    }
    else
    {
        return;
    }
}
int main()
{
    cin>>n>>k;
    smoke(n);
    s=n;
    smoke(n);
    cout<<s<<endl;
}

 

posted @ 2020-07-22 16:26  Drophair  阅读(175)  评论(0编辑  收藏  举报