求助!!

P1150 Peter 的烟

Q__A__Q @ 2020-12-08 21:57:59

求大神帮忙看一下代码!!

#include<bits/stdc++.h>
using namespace std;
int k(int a,int b){
    if(a<b) return a;
    return a+k(a/b,b);
}
int main(){
    int a,b; 
    cin>>a>>b;
    cout<<k(a,b);
    return 0;
}

到底哪里错了??


by NaNO2_Cabbage @ 2020-12-09 21:04:45

因为k个烟蒂=1根烟+1个烟蒂

所以k-1个烟蒂=1根烟


by NaNO2_Cabbage @ 2020-12-09 21:06:56


while(烟蒂>=换)
    {
        烟蒂-=换;
        答案++;
        烟蒂++;
    }

by 永动姬 @ 2020-12-09 23:08:07

qp


|