出局记1,未出局记0
#include <iostream> using namespace::std;
using std::cout;
using std::cin; int main()
{int num,n;cin >> num >> n;int nums[num];for(int i=0; i<num; i++){nums[i]=0;}int t=-1;for(int i=0; i<num-1; i++){for(int j=0; j<n; j++){if(t < num-1){t++;}else{t=0;}if(j == n-1 && nums[t] == 0){nums[t] = 1;}else if(nums[t] == 1){j--;}}}for(int i=0; i<num; i++){if(nums[i] == 0){std::cout << i;}}return 0;
}