Last active
March 18, 2016 02:21
-
-
Save fa7ad/36d401554001ffa7784c to your computer and use it in GitHub Desktop.
Chicken-Egg problem for DIU algo challenge on CodeMarshal.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main() | |
{ | |
int cn; | |
ostringstream out; | |
cin >> cn; | |
for(int i = 0; i < cn; i++){ | |
long double term, counter = 0; | |
cin >> term; | |
while(fmod(term, 2) == 0){ | |
counter++; | |
term = term/2; | |
} | |
if(fmod(counter, 2) == 0){ | |
out << "Chicken First!\n"; | |
}else{ | |
out << "Egg First!\n"; | |
} | |
} | |
cout << out.str(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment