自己测试对了(#2、#3)

P1150 Peter 的烟

chen_1111 @ 2024-05-26 10:44:05

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

by ___define___ @ 2024-05-26 10:45:09

@123A123

#include<bits/stdc++.h>
using namespace std;
int n,k,ans=0;
void z(int n){
    if(n<k) return ;
    ans+=n/k;
    z(n%k+n/k);
}
int main(){
    cin>>n>>k;
    ans=n;
    z(n);
    cout<<ans;
    return 0;
}

求壶关


|