import java.util.*; class Solution { public boolean divisorGame(int N) { if (N ==0){ return false; } Map<Integer, Boolean> st = new HashMap<Integer, Boolean>(); st.put(1,false); for(int i = 2; i<= N; i++){ boolean canWin = false; for(int j = i/2; j>0; j--){ if(i%j ==0){ int r = i-j; if(st.get(r) ==false){ canWin=true; break; } } } st.put(i,canWin); } return (st.get(N)) ; } }
(Easy) Divisor Game LeetCode
猜你喜欢
转载自www.cnblogs.com/codingyangmao/p/11287368.html
今日推荐
周排行