class Solution(object):
def intToRoman(self, num):
"""
:type num: int
:rtype: str
"""
if num > 3999 or num < 1:
return ""
values = [1000,900,500,400,100,90,50,40,10,9,5,4,1]
numerals = ["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]
lists=''
for i in range(0,len(values)):
while num >= values[i]:
num -= values[i]
lists += numerals[i]
return lists

@link http://www.cnblogs.com/zuoyuan/p/3779581.html

leetcode Integer to Roman python的更多相关文章

  1. LeetCode: Integer to Roman 解题报告

    Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be within t ...

  2. [LeetCode] Integer to Roman 整数转化成罗马数字

    Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...

  3. Leetcode Integer to Roman

    Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...

  4. LeetCode——Integer to Roman

    Description: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the r ...

  5. [LeetCode][Python]Integer to Roman

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'https://oj.leetcode.com/problems/integer ...

  6. 【LeetCode】12. Integer to Roman 整数转罗马数字

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 个人公众号:负雪明烛 本文关键词:roman, 罗马数字,题解,leetcode, 力扣, ...

  7. Integer to Roman - LeetCode

    目录 题目链接 注意点 解法 小结 题目链接 Integer to Roman - LeetCode 注意点 考虑输入为0的情况 解法 解法一:从大到小考虑1000,900,500,400,100,9 ...

  8. LeetCode OJ:Integer to Roman(转换整数到罗马字符)

    Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...

  9. LeetCode:12. Roman to Integer (Easy)

    1. 原题链接 https://leetcode.com/problems/roman-to-integer/description/ 2. 题目要求 (1)将罗马数字转换成整数:(2)范围1-399 ...

随机推荐

  1. Linux mint 17中文输入法安装,改动linux mint与windows7双系统启动顺序

    安装好linux mint17后,进入mint系统,首先须要一个比較合适的中文输入法. 一.首先迎来的就是安装中文输入法了,之前听说搜狗为ubuntu kinly定制了输入法,所以就想安装搜狗输入法, ...

  2. ACM/ICPC2014鞍山现场赛E hdu5074Hatsune Miku

    题目链接:pid=5074">http://acm.hdu.edu.cn/showproblem.php?pid=5074 题意: 给定一个m*m的矩阵mp.然后给定一个长度为n的序列 ...

  3. 使用Vitamio打造自己的Android万能播放器(5)——在线播放(播放优酷视频)

    前言 为了保证每周一篇的进度,又由于Vitamio新版本没有发布, 决定推迟本地播放的一些功能(截图.视频时间.尺寸等),跳过直接写在线播放部分的章节.从Vitamio的介绍可以看得出,其支持http ...

  4. ftp 解决不能上传问题

    有人建议整个关掉SELinux并且重启,于是我去/etc/selinux/config里面把SELinux给disable了.重启之后,发现可以在/home/sam/test这个文件夹上传了!

  5. 【巧妙思维】【4-6】Problem F

    题意:有n个正方体,边长为A[i] 当A[k]-A[p]<=lim 时 k可以放在p上面, 问有多少种放法: 一开始被数据范围吓到了 ,以为是n^3算法,答案是nlogn 从小到大排序,一个一个 ...

  6. httpclient response 重定向

    HTTPClient请求后,重定向后,获取重定向的URL. 方法一:重定向后获取URL import org.apache.http.HttpEntity; import org.apache.htt ...

  7. 改良版的SQL Service 通用存储过程分页

    上次写了通用存储过程.感觉还是有很大的BUG.就是条件不能参数画化.这个BUG可以说是致命的.但是我一直想在用什么方法能解决这个东西.其实我只是想写少量的代码来做更多的事情.我想能不能传集合给存储过程 ...

  8. NOIP2012模拟试题【圆圈舞蹈( circle)

    2.圆圈舞蹈( circle) [问题描述] 熊大妈的奶牛在时针的带领下,围成了一个圆圈跳舞.由于没有严格的教育,奶牛们之间的间隔不一致. 奶牛想知道两只最远的奶牛到底隔了多远.奶牛A到B的距离为A顺 ...

  9. CCF计算机认证——字符串匹配问题(运行都正确,为什么提交后只给50分?)

    我的程序: #include<iostream> #include<cctype> #include<string> #include<vector> ...

  10. 在MyEclipse环境下写Struts,删除项目不干净的问题的解决

    这个头疼的问题弄了好几个小时,终于弄好了.方法如下:1.建立一个新的项目,确认自己已经部署好Struts2的环境(网上有好多教程).运行Tomcat还是会有之前的项目的错误,接下来进行第二步2.将To ...