罗马数字转化为十进制的值

题目非常的长

提取有效信息

并且介绍很多规则 但是事实上有用的信息就是如何加

什么时候减 当当前字母小于下一个字母时 减去当前字母的值

 #include <iostream>
#include <stdio.h>
#include <string.h>
#define READ() freopen("in.txt", "r", stdin); using namespace std; int Map(char ch)
{
int n;
switch(ch)
{
case 'I': n = ;break;
case 'V': n = ;break;
case 'X': n = ; break;
case 'L': n = ; break;
case 'C': n = ; break;
case 'D': n = ; break;
case 'M': n = ; break;
default : n = ;break;
}
return n;
}
int main()
{
int T;
char in[];
scanf("%d", &T);
getchar();
while (T--)
{
gets(in);
int ans = ;
int len = strlen(in);
char pre, nxt;
for (int i = ; i < len; i++)
{
pre = in[i];
if(i < len-) nxt = in[i+];
else nxt = ' ';
if (Map(pre) >= Map(nxt)) ans+= Map(pre);
else ans -= Map(pre);
}
printf("%d\n", ans);
}
return ;
}

HDU 2352 Verdis Quo的更多相关文章

  1. HDOJ/HDU 2352 Verdis Quo(罗马数字与10进制数的转换)

    Problem Description The Romans used letters from their Latin alphabet to represent each of the seven ...

  2. HOJ题目分类

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

  3. OJ题解记录计划

    容错声明: ①题目选自https://acm.ecnu.edu.cn/,不再检查题目删改情况 ②所有代码仅代表个人AC提交,不保证解法无误 E0001  A+B Problem First AC: 2 ...

  4. POJ 2352 &amp;&amp; HDU 1541 Stars (树状数组)

    一開始想,总感觉是DP,但是最后什么都没想到.还暴力的交了一发. 然后開始写线段树,结果超时.感觉自己线段树的写法有问题.改天再写.先把树状数组的写法贴出来吧. ~~~~~~~~~~~~~~~~~~~ ...

  5. hdu 1541/poj 2352:Stars(树状数组,经典题)

    Stars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  6. POJ 2352 Stars(HDU 1541 Stars)

    Stars Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 41521   Accepted: 18100 Descripti ...

  7. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  8. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

  9. HDU ACM 题目分类

    模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...

随机推荐

  1. scrollTop、offsetTop、clientTop

    1.offsetTop: obj.offsetTop 指 obj 相对于版面或由 offsetParent 属性指定的父坐标的计算上侧位置. 2.clientTop: 这个返回的是元素周围边框的厚度, ...

  2. checkbox:全选、全不选、单选(慕课网题目)

    任务 1.在第27行处补充完整,实现当点击"全选"按钮时,将选中所有的复选项. 提示:document.getElementsByTagName("input" ...

  3. 清理xcode缓存

    code版本:8.3.3 iOS版本:10.3.2 移除 Xcode 运行安装 APP 产生的缓存文件(DerivedData) 只要重新运行Xcode就一定会重新生成,而且会随着运行程序的增多,占用 ...

  4. JQuery日期选择器插件date-input

    JQuery日期选择器插件之date-input 官方网站:http://jonathanleighton.com/projects/date-input/ 下载地址: http://github.c ...

  5. Java Web开发之Spring | SpringMvc | Mybatis | Hibernate整合、配置、使用

    1.Spring与Mybatis整合 web.xml: <?xml version="1.0" encoding="UTF-8"?> <web ...

  6. Summary of 2016 International Trusted Computing and Cloud Security Summit

    1)      Welcome Remarks 2)      The advancement of Cloud Computing and Tursted Computing national st ...

  7. Codeforces GYM 100741A . Queries

    time limit per test 0.25 seconds memory limit per test 64 megabytes input standard input output stan ...

  8. SQLite-And和OR运算符

    SQLite - AND 和 OR 运算符 SQLite AND . OR运算符用于编译多个条件缩小在一个SQLite声明中选定的数据.这两个操作符被称为连接的操作符. 这些操作符与不同操作提供了一种 ...

  9. 11gR2新特性---gipc守护进程

    在这篇文章中,我们会对11gR2 新的守护进程gipcd(资源名称ora.gipcd)进行介绍,其中包括gipc的功能,启动顺序和一些基本的测试. 我们知道,对于oracle集群来说,集群私网是非常重 ...

  10. (转)使用Spring配置文件实现AOP

    http://blog.csdn.net/yerenyuan_pku/article/details/52880558 使用Spring配置文件实现AOP 前面我们已经学会了使用Spring的注解方式 ...