1 class Solution { 2 public: 3 int LastRemaining_Solution(unsigned int n, unsigned int m) 4 { 5 if(n<1||m<1) 6 return -1; 7 int last=0; 8 for(int i=2;i<=n;i++) 9 last=(last+m)%i;10 return last;11 }12 };
本文共 329 字,大约阅读时间需要 1 分钟。
1 class Solution { 2 public: 3 int LastRemaining_Solution(unsigned int n, unsigned int m) 4 { 5 if(n<1||m<1) 6 return -1; 7 int last=0; 8 for(int i=2;i<=n;i++) 9 last=(last+m)%i;10 return last;11 }12 };
转载于:https://www.cnblogs.com/vaecn/p/5326918.html