90 #3未过 求改

P1150 Peter 的烟

wenxinran @ 2024-07-25 15:46:21

#include<bits/stdc++.h>
using namespace std;
int n,k,ans,m;
int main(){
    scanf("%d %d",&n,&k);
    ans+=n;
    while(n+m>=k){
        n=(n+m)/k;
        m%=k;   
        ans+=n;
    }
    printf("%d",ans);
    return 0;
}

by weak_in_code @ 2024-07-25 15:51:12

@wenxinran 你 m 从始至终都是 0


by wjr_jok @ 2024-07-25 15:57:15

@weak_in_code 不愧是老中医%%%


by wenxinran @ 2024-07-25 16:00:27

@weak_in_code 那是要把m删了吗


by wenxinran @ 2024-07-25 16:03:42

还是没过怎么办qwq

#include<bits/stdc++.h>
using namespace std;
int n,k,ans;
int main(){
    scanf("%d %d",&n,&k);
    ans+=n;
    while(n>=k){
        n=n/k;  
        ans+=n;
    }
    printf("%d",ans);
    return 0;
}

by wjr_jok @ 2024-07-25 16:05:35

@wenxinran 6


by weak_in_code @ 2024-07-25 16:06:02

@wenxinran 看题啊哥。

#include<bits/stdc++.h>
using namespace std;
int n,k,ans;
int main(){
    scanf("%d %d",&n,&k);
    ans+=n;
    while(n>=k){
        ans+=n/k;
        n=n%k+n/k;
    }
    printf("%d",ans);
    return 0;
}

by wjr_jok @ 2024-07-25 16:08:40

@weak_in_code %%%%%%%%老中医妙手回春


by Grace34 @ 2024-07-25 16:11:20

我写的,如果不嫌弃的话可以参考一下

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

by wenxinran @ 2024-07-25 16:17:05

@weak_in_code@Grace34 谢谢谢谢,非常感谢


by wenxinran @ 2024-07-25 16:20:46

终于AC了,谢谢,感谢大佬


| 下一页