LeetCode 1006. 笨阶乘

题目链接

1006. 笨阶乘

class Solution {
public:
    int clumsy(int N) {
        std::ios::sync_with_stdio(false);
        if(N <= 4){
            int res[] = {0, 1, 2, 6, 7};
            return res[N];
        }else{
            int res[] = {1, 2, 2, -1};
            return N + res[N % 4];
        }
    }
};
posted @ 2021-04-01 22:31  蒟蒻颖  阅读(23)  评论(0编辑  收藏  举报