ZOJ_3501 Roman Order
这题应该是个水题,可是我比题还水。。。TT,用map写的,存对应的roma数字时存错啦。。。正好在比赛,我晕,WA了两次,我的排名啊。。。TT
#include <iostream>#include <cstdio>#include <cstdlib>#include <map> using namespace std; map<int, string> m; struct roma{int x;string s;}roma[10010]; void init(){ m[1] = "I";m[2] = "II";m[3] = "III";m[4] = "IV"; m[5] = "V";m[6] = "VI";m[7] = "VII";m[8] = "VIII"; m[9] = "IX";m[10] = "X";m[20] = "XX";m[30] = "XXX"; m[40] = "XL";m[50] = "L"; m[60] = "LX"; m[70] = "LXX";m[80] = "LXXX"; m[90] = "XC";m[100] = "C"; m[200] = "CC";m[300] = "CCC"; m[400] = "CD"; m[500] = "D"; m[600] = "DC"; m[700] = "DCC"; m[800] = "DCCC"; m[900] = "CM"; m[1000] = "M"; m[2000] = "MM"; m[3000] = "MMM";} int cmp ( const void * a , const void * b ){struct roma *c = (struct roma *)a;struct roma *d = (struct roma *)b;return c->s > d->s;} int main(){//freopen("data.in", "r", stdin); int t, n, i, f, tmp; init();string str; while(scanf("%d", &t) != EOF) {while(t--) { scanf("%d", &n);for(i = 0; i < n; i++) { scanf("%d", &f); tmp = f; str.clear();if(f/1000) { str += m[(f/1000)*1000]; f %= 1000; }if(f/100) { str += m[(f/100)*100]; f %= 100; }if(f/10) { str += m[(f/10)*10]; f %= 10; }if(f) { str += m[f]; } roma[i].x = tmp; roma[i].s.clear(); roma[i].s = str; } qsort(roma, n, sizeof(roma[0]), cmp); for(i = 0; i < n-1; i++) { printf("%d ", roma[i].x);//cout << roma[i].s << " " ; } printf("%d\n", roma[n-1].x);//cout << roma[i].s << endl; } }return 0;}
转载于:https://www.cnblogs.com/vongang/archive/2011/09/17/2179732.html
ZOJ_3501 Roman Order相关推荐
- 理解字节序 [Understanding Big and Little Endian Byte Order]
原文地址 (本文对于字节序讲解的很清楚,容易理解.) Problems with byte order are frustrating, and I want to spare you the gri ...
- HDU3999-The order of a Tree
The order of a Tree Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) ...
- 107. Binary Tree Level Order Traversal II
题目 Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from l ...
- 102. Binary Tree Level Order Traversal
题目 Binary Tree Level Order Traversal 层次遍历二叉树 链接 Given a binary tree, return the level order traversa ...
- Mysql分页order by数据错乱重复
公司用的是Mybatis,发现分页和排序时直接传递参数占位符用的都是 ,由于,由于,由于有SQL注入风险,要改为#,但是封装page类又麻烦,所以直接使用了 pageHelper 插件了,方便快捷,但 ...
- select 和 order by
select 的优先级要高于order by,相当于是select先创建了一个临时表,再通过临时表去排序.所以,对于一些sum()的汇总,在进行排序,实际是排序的select后的字段,而不是表里的那个 ...
- access order by 判断是否除数为0
order by IIF(dz>0,yj/dz,0) desc 转载于:https://www.cnblogs.com/slyzly/p/5379482.html
- 【leetcode】Roman to Integer
题目描述: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range fr ...
- PL/SQL第五章 Order by排序
1 -- 排序 2 -- 1.列明排序 3 -- 2.别名排序 4 -- 3.列位置排序(当使用union,union all,intersect,minus集合操作,列明不同,但希望排序) 5 SE ...
最新文章
- java中文乱码解决之道(二)—–字符编码详解:基础知识 + ASCII + GB**
- Mongodb源码分析--插入记录及索引B树构建
- Windows中报错:Fatal error in launcher: Unable to create process using ‘“‘ 的解决方案
- JZOJ 4366. 【GDKOI2016】项链
- boost::make_recursive_variant相关的测试程序
- LINUX内核的进程调度策略
- 利用 ILSpy 查看 C# 代码编译及运行真相
- php shuffle有种子吗6,6个BT种子网站,没有它找不到的资源!太少人知道了怪可惜的...
- 召唤神龙Ladon强化Cobalt Strike
- 第二个项目---EMOS企业在线办公小程序
- 利用echarts中的map地图中的中国地图,并使中国地图显示效果为轮廓显示到市级级别效果(真实项目中亲测有效~)
- MATLAB实现规范化(normalize)数据的函数实现
- 机器学习 ---- 新词发现
- mybatis+mysql查询类别下的所有子类别(递归)
- 有关“SRS Audio Sandbox”的一些问题?
- rasa算法_【RASA系列】语义理解(上)
- pytorch PythonAPI torch.....................
- TypeScript 基础数据类型与接口
- English - every和each的用法和区别
- 微信公众号开发---自定义菜单的创建及菜单事件响应(java)