leetcode-剑指62-OK

// language C with STL(C++)
// 剑指62
// https://leetcode-cn.com/problems/yuan-quan-zhong-zui-hou-sheng-xia-de-shu-zi-lcof/


class Solution {
public:
    int lastRemaining(int n, int m) {
    	int ans = 0;
    	for(int i = 2 ;i<= n ; i++){
    		ans = (ans+m)%i;
    	}
    	return ans;
	}
};
posted @ 2021-02-02 13:58  RougeBW  阅读(26)  评论(0编辑  收藏  举报