#22843: 新手wa5 該怎麼解決


wangli.service.tw@gmail.com (Pineapple)


#include <iostream>

using namespace std;

#define ll long long

int main(){

ll a,b;

while(cin>>a>>b){

ll count = 0;

ll t=0;

while(count < b){

count += a;

count += t;

t++;

}

cout<<t<<endl;

}

}

#22860: Re:新手wa5 該怎麼解決


snakeneedy (蛇~Snake)


要注意題目問的是

總和會超過 m

以你的程式碼

while(count < b){

在 count == b 時就會跳出,會少算