class Solution(object): def clumsy(self, N): """ :type N: int :rtype: int """ op = {0: '*', 1: '//', 2: '+', 3: '-'} strN = list(map(str, range(N - 1, 0, -1))) ret = str(N) for i, s in enumerate(strN): ret += op[i % 4] + s return eval(ret)
class Solution(object): def clumsy(self, N): """ :type N: int :rtype: int """ op = {0: '*', 1: '//', 2: '+', 3: '-'} strN = list(map(str, range(N - 1, 0, -1))) ret = str(N) for i, s in enumerate(strN): ret += op[i % 4] + s return eval(ret)
转载于:https://www.cnblogs.com/zywscq/p/10625183.html