Created
October 12, 2015 11:52
-
-
Save ryoppippi/bcd54addad00cef6614e to your computer and use it in GitHub Desktop.
力ずくで解いたヨセフスの問題。kがならばされた人の数で、l毎に殺されていきます。本当はもっと高尚な数式とかあったけどなあ。使いたいけどそれは主旨と違う。 #coding #課題 #CodePiece
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
| int list[k]; | |
| for ( b = 0; b < k; b++) { | |
| list[b] = 0; | |
| } | |
| int alive = k; | |
| int check = -1; | |
| while (alive !=0) { | |
| for (c = 0; c < l; c++) { | |
| do { | |
| check++; | |
| if (check >= k) { | |
| check -=k; | |
| } | |
| } while(list[check] == 1); | |
| } | |
| list[check] = 1; | |
| alive -=1; | |
| } | |
| printf("%d\n", check+1); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment