玄关求条

P1150 Peter 的烟

lihongxing @ 2024-09-23 21:00:25

#include<iostream>
int main()
{long long k,n;
std::cin>>n>>k;
n+=(n-1)/(k-1);
std::cout<<n<<endl;}

by goIdie @ 2024-09-23 21:02:12

@lihongxing endl改成std::endl


by CMWabc123 @ 2024-09-23 21:05:42

也可以大模拟

#include <iostream>
using namespace std;
int main() {
    int n,k,s,q;
    cin>>n>>k;
    s=q=n;
    while(q>=k) {
        s+=(q/k);
        q=(q/k)+(q%k);
    }
    cout<<s;
    return 0;
}

当然,楼主的方法也行,问题同楼上


|