90!!!求调

P1150 Peter 的烟

timi520 @ 2024-12-31 19:35:32

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

by msh20204401 @ 2024-12-31 20:05:21

你不开long long 吗?人家数据10的18次方 int 会爆


by msh20204401 @ 2024-12-31 20:17:38

你是不是WA第三个了???

如果是的话,那你就特判一下,输出19


by honguozhi @ 2024-12-31 20:43:38

@timi520

#include<bits/stdc++.h>
using namespace std;
int main(){
    int yd=0,cy=0,a,b;
    cin>>a>>b;
    yd+=a;
    cy+=a;
    while(yd>=b){
        cy+=yd/b;
        yd=yd/b+yd%b;
    }
    cout<<cy;
return 0;
}

by honguozhi @ 2024-12-31 20:45:03

你忘了除完后剩下的烟袋了吗?


by honguozhi @ 2024-12-31 20:45:56

求关 owo


by timi520 @ 2025-01-03 14:21:16

O(∩_∩)O谢谢!!!已回关


|