Last active
December 18, 2015 01:29
-
-
Save yongpitt/5704016 to your computer and use it in GitHub Desktop.
Snapper Chain Solution (Google Code Jam Qualification Round 2010)
This file contains hidden or 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
| /*Snapper Chain Solution (Google Code Jam Qualification Round 2010)*/ | |
| //For problem statement please go to: https://code.google.com/codejam/contest/433101/dashboard | |
| //Easy problem. Done within 30 minutes and passed all tests. | |
| void SnapperChain::PrintOnOff(ifstream &infile) | |
| { | |
| int T, N, K; | |
| infile >> T; | |
| ofstream outfile("D:/tests/SnapperChain.out"); | |
| for(int i=1; i<=T; i++){ | |
| infile >> N >> K; | |
| long long int cycle = pow(2.0, N); | |
| long long int start = cycle-1; | |
| if((K>=start) && (K-start) % cycle == 0) | |
| outfile << "Case #" << i << ": ON" << endl; | |
| else | |
| outfile << "Case #" << i << ": OFF" << endl; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment