#11528: 這題測資5是什麼?


maple3142 (maple3142)

學校 : 國立新竹高級中學
編號 : 58619
來源 : [114.34.128.210]
最後登入時間 :
2025-10-01 23:52:13

測資5 一直TLE

#include<iostream>
using namespace std;

int main(void){
double n,m;
while(cin>>n>>m){
double b=0;
for(double h=1;b<n;h++){
b=(1+(1+(h-1)*m))*h/2;
}
cout<<(n==b?"Go Kevin!!":"No Stop!!")<<endl;
}
return 0;
}

 

#11662: Re:這題測資5是什麼?


kaihsinchen (Kai-Hsin Chen)

學校 : 國立高雄師範大學附屬高級中學
編號 : 56928
來源 : [140.113.232.81]
最後登入時間 :
2025-10-02 23:27:38

測資5 一直TLE

#include
using namespace std;

int main(void){
double n,m;
while(cin>>n>>m){
double b=0;
for(double h=1;b<n;h++){
b=(1+(1+(h-1)*m))*h/2;
}
cout<<(n==b?"Go Kevin!!":"No Stop!!")<<endl;
}
return 0;
}

 


這題第5個測資似乎有好幾行

我只有測前幾個

好像都是2147483647  0

你就寫一個if判斷式:如果m==0就輸出Go Kevin!!     (感謝a5083)