用这个函数转成罗马数字统计就行了。

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#define mkp make_pair
using namespace std;
const double EPS=1e-;
typedef long long lon;
const lon SZ=,INF=0x7FFFFFFF; string intToRoman(int num) {
string c[][]={
{"","I","II","III","IV","V","VI","VII","VIII","IX"},
{"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"},
{"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"},
{"","M","MM","MMM"}};
string roman;
roman.append(c[][num / % ]);
roman.append(c[][num / % ]);
roman.append(c[][num / % ]);
roman.append(c[][num % ]); return roman;
} int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
lon casenum;
//cin>>casenum;
//for(lon time=1;time<=casenum;++time)
{
int n;
cin>>n;
map<char,int> mp;
for(int i=;i<=n;++i)
{
string tmp=intToRoman(i);
for(int j=;j<tmp.size();++j)
{
++mp[tmp[j]];
}
}
if(mp['I'])cout<<'I'<<" "<<mp['I']<<endl;
if(mp['V'])cout<<'V'<<" "<<mp['V']<<endl;
if(mp['X'])cout<<'X'<<" "<<mp['X']<<endl;
if(mp['L'])cout<<'L'<<" "<<mp['L']<<endl;
if(mp['C'])cout<<'C'<<" "<<mp['C']<<endl;
if(mp['D'])cout<<'D'<<" "<<mp['D']<<endl;
if(mp['M'])cout<<'M'<<" "<<mp['M']<<endl;
}
return ;
}

string intToRoman(int num) {
string c[4][10]={
{"","I","II","III","IV","V","VI","VII","VIII","IX"},
{"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"},
{"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"},
{"","M","MM","MMM"}};
string roman;
roman.append(c[3][num / 1000 % 10]);
roman.append(c[2][num / 100 % 10]);
roman.append(c[1][num / 10 % 10]);
roman.append(c[0][num % 10]);

return roman;
}

p1465 Preface Numbering的更多相关文章

  1. USACO 2.2 Preface Numbering

    Preface Numbering A certain book's prefaces are numbered in upper case Roman numerals. Traditional R ...

  2. P1465 序言页码 Preface Numbering (手推)

    题目描述 一类书的序言是以罗马数字标页码的.传统罗马数字用单个字母表示特定的数值,以下是标准数字表: I 1 V 5 X 10 L 50 C 100 D 500 M 1000 最多3个同样的可以表示为 ...

  3. 【USACO 2.2】Preface Numbering (找规律)

    求 1-n 的所有罗马数字表达中,出现过的每个字母的个数. 分别对每个数的罗马表达式计算每个字母个数. 对于十进制的每一位,都是一样的规则,只是代表的字母不同. 于是我们从最后一位往前考虑,当前位由字 ...

  4. USACO Section 2.2: Preface Numbering

    搬了leetcode的代码 /* ID: yingzho1 LANG: C++ TASK: preface */ #include <iostream> #include <fstr ...

  5. USACO Preface Numbering 构造

    一开始看到这道题目的时候,感觉好难 还要算出罗马的规则. 但是仔细一看,数据规模很小, n 只给到3500 看完题目给出了几组样例之后就有感觉了 解题方法就是: n的每个十进制数 转换成相应的罗马数字 ...

  6. USACO Section2.2 Preface Numbering 解题报告 【icedream61】

    preface解题报告----------------------------------------------------------------------------------------- ...

  7. Preface Numbering

    链接 分析:先打表需要用到的罗马数字,然后暴力转换,最后统计一下即可 /* PROB:preface ID:wanghan LANG:C++ */ #include "iostream&qu ...

  8. Preface Numbering序言页码

    题面 (preface.pas/c/cpp) 一类书的序言是以罗马数字标页码的.传统罗马数字用单个字母表示特定的数值,以下是标准数字表: I 1 V 5 X 10 L 50 C 100 D 500 M ...

  9. USACO2.2 Preface Numbering【思维+打表】

    这道题乍一看没有什么思路,细看还是没有什么思路 嗯,细看还是可以看出些什么端倪. 不能复合嵌套什么的 总结一下就只有这样3种规则: 1.IXCM最多三个同样连续 加起来2.递减:加起来 注意VLD不连 ...

随机推荐

  1. Spring Boot源码分析

    1.核心: SpringApplication.run(SpringbootdemoApplication.class, args); 内部 2.初始化: new SpringApplication( ...

  2. 比较好的一些 ConcurrentHashMap讲解博客

    jdk8 https://blog.csdn.net/jianghuxiaojin/article/details/52006118#commentBox jdk7.8 https://crossov ...

  3. office完全卸载

    第一步:先暂停office服务,再通过 控制面板--卸载程序  --卸载office应用 第二步:通过office_move(自己命名的工具)软件卸载  工具分享:https://pan.baidu. ...

  4. 良好的GUI设计指南

    一.设计指南 摘自:<需求分析与系统设计(第3版)> 7.1.2. 1. 用户控制 用户事件(菜单动作.鼠标点击.屏幕光标移动等)打开GUI窗口或调用程序:程序执行需要反馈到用户. 2.  ...

  5. Footnotes for tables in latex - 为latex的table加上footnotes

    参考: Footnotes for tables in LaTeX Footnote in tabular environment Footnotes for tables in latex - 为l ...

  6. PS与PL协同设计

    https://blog.csdn.net/Fei_Yang_YF/article/details/79676172 什么是PS和PL ZYNQ-7000是Xilinx推出的一款全可编程片上系统(Al ...

  7. js捕获错误

    文: http://www.jb51.net/article/78764.htm 用window.onerror捕获并上报Js错误的方法 前两天有个2048游戏的用户反馈说,打开游戏后不能玩儿,只有一 ...

  8. 基因组与Python --PyVCF 好用的vcf文件处理器

    vcf文件的全称是variant call file,即突变识别文件,它是基因组工作流程中产生的一种文件,保存的是基因组上的突变信息.通过对vcf文件进行分析,可以得到个体的变异信息.嗯,总之,这是很 ...

  9. 在用node安装某个全局模块的时候,没有权限修改node_modules

    一.问题 今天在安装公司内部的一个npm模块的时候,发现报错了⬇ 第一行错误: deprecated graceful-fs@1.2.3: please upgrade to graceful-fs ...

  10. _talent_req

    学习天赋时,将产生消耗,当玩家已经学习过该天赋时,不产生消耗 comment 备注 spellId 天赋技能ID reqId 消耗模板ID,对应_req表中reqId