fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. int n, k, p;
  5. cin >> n >> k;
  6. int person = 0;
  7. for (int count = 2; count <= n; count++) person = (person + k) % count;
  8. cout << person+1;
  9. return 0;
  10. }
Success #stdin #stdout 0s 15232KB
stdin
10 3
stdout
1 1 0 3 0 3 6 0 3 4