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


maple3142 (maple3142)


測資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)


測資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)