#20498: 請問為甚麼測資2.4過不去呢


twm0970420996@gmail.com (小胖胖胖)


#include <iostream>
using namespace std;
int main(){
long long int S ,E;

while( cin >> S >> E ){
bool mar = false;
for(int i = 1 ; i <= S ; i += E){
if(i == S){
mar = true;
}
}
if( mar == true ){
cout << "Go Kevin!!" << endl;
}else{
cout << "No Stop!!" << endl;
}
}
return 0;
}

 

 

 

感謝!!

#20499: Re:請問為甚麼測資2.4過不去呢


wanttogo0718@gmail.com (Hello World)


#include
using namespace std;
int main(){
long long int S ,E;

while( cin >> S >> E ){
bool mar = false;
for(int i = 1 ; i <= S ; i += E){
if(i == S){
mar = true;
}
}
if( mar == true ){
cout << "Go Kevin!!" << endl;
}else{
cout << "No Stop!!" << endl;
}
}
return 0;
}

 

 

 

感謝!!

是每次都比「上一次」多摘m朵花瓣,再想想看for迴圈那邊吧

 

#20502: Re:請問為甚麼測資2.4過不去呢


asnewchien@gmail.com (david)


 


這題別用迴圈解,

可以簡化成 一元二次方程式 來判斷。

#20504: Re:請問為甚麼測資2.4過不去呢


twm0970420996@gmail.com (小胖胖胖)


#include
using namespace std;
int main(){
long long int S ,E;

while( cin >> S >> E ){
bool mar = false;
for(int i = 1 ; i <= S ; i += E){
if(i == S){
mar = true;
}
}
if( mar == true ){
cout << "Go Kevin!!" << endl;
}else{
cout << "No Stop!!" << endl;
}
}
return 0;
}

 

 

 

感謝!!

是每次都比「上一次」多摘m朵花瓣,再想想看for迴圈那邊吧

 



#include <iostream>

using namespace std;

int main(){

 long long int s , leaf ,sum = 0;

 while(cin >> s >> leaf){

    bool mar = false;

    for(int i = 1 ; i < s ; i += leaf){

        sum += i ;

        if(sum == s){

            mar = true;

        }

    }

    if(mar == true){

        cout << "Go Kevin!!" << endl;

    }else{

        cout << "No Stop!!" << endl;

    }

    sum = 0;

 }

 return 0;

}

大大迴圈部分改好了~ 可是為什麼第3個改long long int 就可以了 ?

最後一個測資過不了呢?