求大佬指正

P1150 Peter 的烟

jiakunnan @ 2023-10-02 18:17:15

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

by cly312 @ 2023-10-02 18:22:29

k一定是3?

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

by jiakunnan @ 2023-10-03 17:29:59

@cly312 谢谢


|