12 Integer to Roman(int转罗马数字Medium)
题目意思:1-3999转罗马数字
思路:从大往小减
ps:这题有点蛋疼
class Solution {
public:
string intToRoman(int num) {
string a[]={"I","IV","V","IX","X","XL","L","XC","C","CD","D","CM","M"};
int b[]={,,,,,,,,,,,,};
string str="";
for(int i=;i>=;--i){
while(num>=b[i]){
str+=a[i];
num=num-b[i];
}
}
return str;
}
};
12 Integer to Roman(int转罗马数字Medium)的更多相关文章
- [LeetCode] 12. Integer to Roman 整数转为罗马数字
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 ...
- 【LeetCode】12. Integer to Roman 整数转罗马数字
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 个人公众号:负雪明烛 本文关键词:roman, 罗马数字,题解,leetcode, 力扣, ...
- [leetcode]12. Integer to Roman整数转罗马数字
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 ...
- Leetcode 12. Integer to Roman(打表,水)
12. Integer to Roman Medium Roman numerals are represented by seven different symbols: I, V, X, L, C ...
- Leetcode 12——Integer to Roman
12.Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be withi ...
- leetCode练题——12. Integer to Roman
1.题目 12. Integer to Roman Roman numerals are represented by seven different symbols: I, V, X, L, C, ...
- lintcode :Integer to Roman 整数转罗马数字
题目 整数转罗马数字 给定一个整数,将其转换成罗马数字. 返回的结果要求在1-3999的范围内. 样例 4 -> IV 12 -> XII 21 -> XXI 99 -> XC ...
- 《LeetBook》leetcode题解(12):Integer to Roman[M]
我现在在做一个叫<leetbook>的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看 书的地址:https://hk029.g ...
- 【LeetCode】12. Integer to Roman (2 solutions)
Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be within t ...
随机推荐
- CF 85D Sum of Medians (五颗线段树)
http://codeforces.com/problemset/problem/85/D 题意: 给你N(0<N<1e5)次操作,每次操作有3种方式, 1.向集合里加一个数a(0< ...
- 数学(动态规划,GCD):COGS 469. [NOI2010]能量采集
能量采集 ★★☆ 输入文件:energy2010.in 输出文件:energy2010.out 简单对比 时间限制:1 s 内存限制:512 MB [问题描述] 栋栋有一块长方形的地, ...
- 怎么用copy关键字
出题者简介: 孙源(sunnyxx),目前就职于百度 整理者简介:陈奕龙,目前就职于滴滴出行. 转载者:豆电雨(starain)微信:doudianyu 用途: NSString.NSArray.NS ...
- php 数组排序 (转)
// @param array $list 查询结果 // @param string $field 排序的字段名 // @param array $sortby 排序类型 // asc正向排序 de ...
- Android(java)学习笔记230:服务(service)之绑定服务的细节
绑定服务的细节 1. 如果onbind方法返回值是null,onServiceConnect方法就不会被调用: 2. 绑定的服务,在系统设置界面,正在运行条目是看不到的: 3. 绑定的服务,不求同时生 ...
- Day7 - Python基础7 面向对象编程进阶
Python之路,Day7 - 面向对象编程进阶 本节内容: 面向对象高级语法部分 经典类vs新式类 静态方法.类方法.属性方法 类的特殊方法 反射 异常处理 Socket开发基础 作业:开发一个 ...
- 洛谷 1373 小a和uim之大逃离
/* 很容易想到f[i][j][k][l][01] 表示到ij点 两个人得分为kl 01表示这一步谁走的 因为起点不同 路径不同 所以要枚举起点.. 时间复杂度 O(nmk*nmk) 空间复杂度 O( ...
- noip 2013 华容道
/*双向bfs (得分和单项的一样多....)70*/ #include<iostream> #include<cstdio> #include<cstring> ...
- border属性妙用
以前只知道border属性是盒模型中的边框属性,一直不清楚每个边的border是矩形拼接有重合呢,还是梯形无缝拼接的. border梯形 为了观察边框究竟是哪一种拼接方式,为边框设置不同的颜色背景,代 ...
- dede织梦后台页面及功能修改及精简操作方法
先让我们来看看都有哪些页面控制着后台的功能和显示.下方为系统默认的后台界面图,为了便于下面的说明我对各个部分进行了一些标示.共A.B.C.D.E五个区域. 常用:A区域[顶部LOGO行]对应文件:/d ...