Created
November 25, 2017 00:43
-
-
Save lastday154/952a364b5a6459d83c279129dbed4972 to your computer and use it in GitHub Desktop.
Tournament Honestbee
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
| #include <iostream> | |
| #include <vector> | |
| using namespace std; | |
| int tour(int num_kid, int x) | |
| { | |
| vector<int> v; | |
| for (int i=0; i<num_kid; i++) { | |
| v.push_back(i); | |
| } | |
| while(v.size() != 1) | |
| { | |
| int n = v.size(); | |
| int pos = x%n - 1; | |
| if (pos < 0) | |
| { | |
| pos = n-1; | |
| } | |
| v.erase(v.begin() + pos); | |
| } | |
| return v[0]; | |
| } | |
| int main() | |
| { | |
| cout<<tour(5,4); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment