Skip to content

Instantly share code, notes, and snippets.

@fa7ad

fa7ad/chickenEgg.cpp

Last active Mar 18, 2016
Embed
What would you like to do?
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