90分!!!第三个点

P1150 Peter 的烟

imbecile @ 2021-06-23 17:32:14

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int sum=n;
    while(n-k>0)
    {
        sum++;
        n-=k;
        n++;
    }
    cout<<sum;
}

by _Haoomff_ @ 2021-06-23 17:37:37

while(n-k>0)
    {
        sum++;
        n-=k;
        n++;
    }

改为

while(n>=k)
{
    sum+=n/k;
    n=n%k+n/k;
}

by imbecile @ 2021-06-23 17:50:25

@L_YALONG 谢谢


|