Skip to content

Instantly share code, notes, and snippets.

@fa7ad
Last active March 18, 2016 02:21
Show Gist options
  • Save fa7ad/36d401554001ffa7784c to your computer and use it in GitHub Desktop.
Save fa7ad/36d401554001ffa7784c to your computer and use it in GitHub Desktop.
Chicken-Egg problem for DIU algo challenge on CodeMarshal.
#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