Logo
(追記) (追記ここまで)

34483번 - Score Values 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB57311451.852%

문제

Ever since you arrived at your university, you have been a tireless advocate for introducing the brand-new martial-artsplus-card-based sport of Contact Bridge to the school (and the world). Finally, after a great deal of (really persistent and annoying) advocacy on your part, you have obtained permission and funding from your dean to build a grand new arena for the sport! Well, technically it is not so much an “arena” as a “broom closet,” and maybe not “grand” so much as “cramped,” and the “new” is also debatable. But the sport of the future has to start somewhere!

Unfortunately, you just realized that you are going to need a score display in order to run the games. In Contact Bridge, the score for a team starts at 0ドル$ and, after various repeatable actions, may be incremented by certain fixed amounts. There is also a maximum value – if the team’s score would be incremented above the maximum, it will instead be capped there. You want the team’s score to be visible at all times, so you will need to prepare some signs, each with a single digit printed on it, that can be arranged to show the score.

Unfortunately the dean’s “funding” is running short, and these signs are expensive. Figure out the minimum set of signs you need to purchase to show any score that is possible to achieve during the game. Note that you won’t need any 9 signs, as any 6 sign can be turned upside-down to make a 9.

입력

The first line of input contains two integers $m$ and $n,ドル where $m$ (1ドル ≤ m ≤ 10^{18}$) is the maximum score value, and $n$ (1ドル ≤ n ≤ 10$) is the number of different ways of scoring. This is followed by $n$ lines, each containing an integer $p$ (1ドル ≤ p ≤ 1,円 000$), which is the number of points awarded for a type of action in the game. No two types of action are awarded the same number of points.

출력

For each digit from 0ドル$ to 8ドル$ in increasing order, output two integers: the digit and the number of signs with that digit that you need to purchase. Omit digits where the number of signs needed is 0ドル$.

제한

예제 입력 1

1000 4
60
100
222
650

예제 출력 1

0 3
1 1
2 3
3 1
4 3
5 1
6 3
7 2
8 3

예제 입력 2

967 1
1000

예제 출력 2

0 1
6 2
7 1

노트

출처

ICPC > World Finals > ICPC World Finals 2025 H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /