Created
September 9, 2014 19:26
-
-
Save msg7086/03a1eafe4c13566236bc to your computer and use it in GitHub Desktop.
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 <stdio.h> | |
| int main() { | |
| int m, n; | |
| scanf("%d%d", &m, &n); | |
| int p[m], j = m - 1; | |
| for(int i = 0; i < m - 1; i++) p[i] = i + 1; | |
| p[m - 1] = 0; | |
| while(p[j] != j) { | |
| for(int i = 0; i < n - 1; i++) j = p[j]; | |
| p[j] = p[p[j]]; | |
| } | |
| printf("%d\n", j); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment