#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;
}
感謝!!
#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
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 就可以了 ?
最後一個測資過不了呢?