剑指offer---孩子们的游戏
class Solution { public: int LastRemaining_Solution(int n, int m) { if (n<1 || m<1) { return -1; } int* sup = new int[n]; int count = n; int i = -1; int step = 0; while (count>0) { ++i; if (i >= n) { i = 0; } while (sup[i] == -1) { ++i; if (i >= n) { i = 0; } } ++step; if (step == m) { sup[i] = -1; step = 0; --count; } } return i; } };