// 21:01 - 21:21 #include int step(int cur, int *dead, int N, int M) { for (int i = 0; i < M; i++) { cur = (cur + 1) % N; while (dead[cur] == 1) { cur = (cur + 1) % N; } } return cur; } int main(void) { int N, M; scanf("%d,%d", &N, &M); int deadCount = 0; int dead[N]; for (int i = 0; i < N; i++) { dead[i] = 0; } int cur = 0; while (1) { cur = step(cur, dead, N, M); dead[cur] = 1; deadCount++; if (deadCount == N) { printf("%d", cur + 1); break; } else { printf("%d,", cur + 1); } cur = step(cur, dead, N, 1); } return 0; }