90分求调

P1150 Peter 的烟

yufan_Arvin @ 2024-10-07 14:29:57

#include<bits/stdc++.h>
using namespace std;
int n,k;
int chouyan(int many,int give)
{
    if(many<k)return many;
    return many+chouyan((many-many%give)/give,give);
}
int main(){
    cin>>n>>k;
    cout<<chouyan(n,k);
    return 0;
}

by sea_water @ 2024-10-07 14:56:37

#include<bits/stdc++.h>
using namespace std;
int n,k,x,z;
int chouyan(int many,int give)
{

    if(many+x<k)return many;
     x=(z+x)%give;
     z=many;
    return many+chouyan((many+x)/give,give);
}
int main(){
    cin>>n>>k;
    cout<<chouyan(n,k);
    return 0;
}

改过了


by sea_water @ 2024-10-07 14:56:58

求关


by yufan_Arvin @ 2024-10-07 15:59:13

ok


|