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; }
作者:Drophair
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利。