[Leetcode]012. Integer to Roman
public class Solution {
public String intToRoman(int num) {
String M[] = {"", "M", "MM", "MMM"};
String C[] = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
String X[] = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
String I[] = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
return M[ num/1000 ] +
C[ (num%1000) / 100] +
X[(num%100)/10] +
I[num%10];
}
}
[Leetcode]012. Integer to Roman的更多相关文章
- 【JAVA、C++】LeetCode 012 Integer to Roman
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...
- [LeetCode][Python]Integer to Roman
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'https://oj.leetcode.com/problems/integer ...
- 【leetcode】Integer to Roman
Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be within t ...
- 【leetcode】Integer to Roman & Roman to Integer(easy)
Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within t ...
- No.012 Integer to Roman
12. Integer to Roman Total Accepted: 71315 Total Submissions: 176625 Difficulty: Medium Given an int ...
- 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--No.012 Integer to Roman
12. Integer to Roman Total Accepted: 71315 Total Submissions: 176625 Difficulty: Medium Given an int ...
- Leetcode 12. Integer to Roman(打表,水)
12. Integer to Roman Medium Roman numerals are represented by seven different symbols: I, V, X, L, C ...
- 【LeetCode】012. Integer to Roman
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...
随机推荐
- 表达式(exp)
题目大意 给定一个逻辑表达式,求每一个数满足$\in[1,n]$的使的表达式为真的方案数. 题解 题目限制较奇怪且数据范围较小,所以可以考虑直接暴力. 考虑枚举每一个变量一共出现了$k$种数值,再枚举 ...
- BZOJ4676 Xor-Mul棋盘
传送门 题目大意懒得写了,题目说的挺明白的了 题解 主要的难点在于异或意义下的最大值和很玄学,但不难发现这道题中让你定义的$D_{i,j}$只参与异或运算,所以我们可以逐位进行讨论.所以我们每一位就只 ...
- POJ1456:Supermarket
浅谈堆:https://www.cnblogs.com/AKMer/p/10284629.html 题目传送门:http://poj.org/problem?id=1456 把物品按照时间排序,显然\ ...
- 简单易懂dubbo入门实例
一.创建Maven多模块项目 项目结构如下 模块介绍: dubbo-api ----API接口 dubbo-consumer ----消费者 dubbo-provider ...
- 杂项-协议-HTTP:GET/POST/PUT/DELETE/INPUT/TRACE/OPTIONS/HEAD方法
ylbtech-杂项-协议-HTTP:GET/POST/PUT/DELETE/INPUT/TRACE/OPTIONS/HEAD方法 1.返回顶部 1. 请求方法是请求一定的Web页面的程序或用于特定的 ...
- 开发框架:AdminLTE
ylbtech-开发框架:AdminLTE 1.返回顶部 2.返回顶部 3.返回顶部 4.返回顶部 1. 2. 5.返回顶部 1. https://adminlte.io 2. 6.返 ...
- Android audioManager
Android audioManager AudioManager provides access to volume and ringer mode control. 获取对象 Use Contex ...
- HBase 二级索引与Coprocessor协处理器
Coprocessor简介 (1)实现目的 HBase无法轻易建立“二级索引”: 执行求和.计数.排序等操作比较困难,必须通过MapReduce/Spark实现,对于简单的统计或聚合计算时,可能会因为 ...
- 我推荐的一些C\C++书籍
原文链接: 我推荐的一些C\C++书籍 人们常常问我有什么C++和编程的书籍推荐,也许是因为我在PowerDNS有一个关于"编写可读性良好的C++代码"的演讲.这篇博文可以作为我对 ...
- Angular08 依赖注入
1 angular应用中依赖注入的工作原理 技巧01:在模块级别进行注册时所有在应用级别的组件都可以使用,因为主模块会导入其他模块,所以在模块中注入就相当于在主模块进行注入操作:懒加载的模块除外 技巧 ...