RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 ICPC00147

I. IXth Problem

스페셜 저지 — 출력을 사용자 정의 프로그램으로 검사하므로 여러 정답이 인정될 수 있습니다.
설명

Emily recently learned about the Roman Empire and its civilization at school. One aspect that was especially fascinating to her is the number system that they used, the Roman numerals. The Roman number system uses seven distinct digits, each representing a different value and denoted by a letter, where I is \(1\), V is \(5\), X is \(10\), L is \(50\), C is \(100\), D is \(500\) and M is \(1\,000\). Multiples of \(1\), \(10\), \(100\) and \(1\,000\) are then written according to the following table:

\(\times\) | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 \(1\) | I | II | III | IV | V | VI | VII | VIII | IX \(10\) | X | XX | XXX | XL | L | LX | LXX | LXXX | XC \(100\) | C | CC | CCC | CD | D | DC | DCC | DCCC | CM \(1\,000\) | M | MM | MMM

Most of the numerals in this table are formed additively, i.e. by summing the values of the digits. For example, LXX is \(50+10+10=70\). Columns \(4\) and \(9\), however, use so-called subtractive notation, where IV is read as \(5-1\), IX is read as \(10-1\), and so on.

Each number from \(1\) to \(3\,999\) is written as a combination of numerals from the table, using at most one numeral from each row and going from bottom to top. For instance, \(2\,021\) is MMXXI and \(594\) is DXCIV. Note that in this number system it is not possible to write numbers greater than \(3\,999\) and also that subtractive notation can only be used in the six cases above (e.g. IC is not considered a valid Roman numeral).

Emily found a bunch of old Scrabble sets in her attic. She threw out all the tiles with letters other than the Roman digits and started forming Roman numerals from the remaining tiles. It is easy to form valid numerals from the tiles by using just one tile per numeral, but what is the minimal number of numerals that can be formed while still using all the available tiles?

제약
입력 형식

The input consists of:
- One line with seven integers \(m\), \(d\), \(c\), \(\ell\), \(x\), \(v\) and \(i\) (\(0 \le m,d,c,\ell,x,v,i \le 10^{18}\)), which respectively are the number of M, D, C, L, X, V and I tiles that must be used.

There is at least one tile, that is \(m+d+c+\ell+x+v+i \ge 1\).

출력 형식

Output an integer \(n\), the minimal possible number of Roman numerals that can be formed while using all of the tiles in the input. Then output an optimal solution in the following format.
- An integer \(k\), the number of distinct Roman numerals used in this solution.
- \(k\) pairs of a Roman numeral and a positive integer indicating how often this numeral is used in this solution.

The solution must consist of exactly \(n\) numerals in total and must use exactly the specified number of each letter. The \(k\) Roman numerals in the solution must be distinct. You do not need to minimize \(k\). If there is more than one optimal solution, any one of them will be accepted.

예제 1
입력
4 1 7 1 3 1 3
출력
2
2
MMDCCCLXX 1
MMCCCXCVIII 1
예제 2
입력
0 0 0 300 2000 1000 2100
출력
1000
2
XXVIII 700
LXXV 300
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NWERC 2021

평가 및 의견

I. IXth Problem

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

I. IXth Problem

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8