Leetcode 1006. Clumsy Factorial
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)
Leetcode 1006. Clumsy Factorial的更多相关文章
- 【LeetCode】1006. Clumsy Factorial 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 直接eval 日期 题目地址:https://lee ...
- 【leetcode】1006. Clumsy Factorial
题目如下: Normally, the factorial of a positive integer n is the product of all positive integers less t ...
- [Swift]LeetCode1006. 笨阶乘 | Clumsy Factorial
Normally, the factorial of a positive integer n is the product of all positive integers less than or ...
- Leetcode 1006. 笨阶乘
1006. 笨阶乘 显示英文描述 我的提交返回竞赛 用户通过次数305 用户尝试次数347 通过次数309 提交次数665 题目难度Medium 通常,正整数 n 的阶乘是所有小于或等于 n 的 ...
- 【LeetCode】172. Factorial Trailing Zeroes
Factorial Trailing Zeroes Given an integer n, return the number of trailing zeroes in n!. Note: Your ...
- 【一天一道LeetCode】#172. Factorial Trailing Zeroes
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...
- LeetCode算法题-Factorial Trailing Zeroes(Java实现)
这是悦乐书的第183次更新,第185篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第42题(顺位题号是172).给定一个整数n,返回n!中的尾随零数.例如: 输入:3 输 ...
- 【LeetCode】172. Factorial Trailing Zeroes 解题报告(Java & Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 递归 循环 日期 题目描述 Given an integer ...
- Swift LeetCode 目录 | Catalog
请点击页面左上角 -> Fork me on Github 或直接访问本项目Github地址:LeetCode Solution by Swift 说明:题目中含有$符号则为付费题目. 如 ...
随机推荐
- rest字符串匹配模式-初次实现方案
一般的rest访问的路径如同这样的路径 http://localhost:8080/AppName/{class}/{method}/{param1}/{param2}... rest的方法分:POS ...
- spring的线程安全
Spring作为一个IOC/DI容器,帮助我们管理了许许多多的“bean”.但其实,Spring并没有保证这些对象的线程安全,需要由开发者自己编写解决线程安全问题的代码.Spring对每个bean提供 ...
- HDU4639
/*计算里面有多少个相邻的he,1个he就是1种意思,两个就是,两种,所以这是 一个斐波拉期数列,间隔的hehe互不影响所以是互斥事件,直接相乘就可以*/ #include<stdio.h> ...
- 【笔记】H5自适应(待)
参考: 1.盒子模型:http://www.cnblogs.com/sunyunh/archive/2012/09/01/2666841.html 2.浮动:http://www.w3school.c ...
- Oracle loop、while、for循环
Loop循环 Declare p_sum ; p_i number; Begin p_i :; Loop p_sum := p_sum + p_i; p_i :; ) then SYS.Dbms_Ou ...
- HDU 5703
题意:给你一个数n,问将n分为正整数和的方案数.如n=3共四种,1 1 1 , 1 2 , 2 1 ,3 . 思路:隔板法,n个1,有n-1个空位,每个空位可以选择是否插入隔板,插入k(0<=k ...
- spark启动
注意在启动spark时候要指定参数 要不就死启动的单机版的 /usr/local/spark-1.5.2-bin-hadoop2.6/bin/spark-shell \ --master spark: ...
- php数组元素去空,测试奇数偶数
<?php//返回奇数 function test_odd($var) { return($var & 1); } $a1=array("a","b&quo ...
- 选择使用Spring框架的原因(Spring框架为企业级开发带来的好处有哪些)
- 分布式技术 webapi 路由追加html、aspx、shtml 适用于 对接 安卓、IOS
首先是这样,在对接安卓和IOS或者是第三方调用的接口,我需要在服务端返回一个带.html/.aspx这样后缀的接口. 例子如下图:http://localhost:64131/api/UsersInf ...