아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

DnD Dice

면접 대비

시간 제한1초메모리 제한1024 MB

요약
d4, d6, d8, d12, d20 주사위의 개수가 주어질 때, 나올 수 있는 모든 합을 확률이 높은 순서대로 나열한다.
난이도

보통10점 중 6점

유형
동적 계획법, 확률, 정렬, 수학
정답자
아직 제출이 없습니다

문제

In Dungeons & Dragons (DnD) and many other role playing games, many actions are determined by dice rolls, and it is also quite common to use dice with different numbers of sides. The most common dice are those based on the five Platonic solids, the tetrahedron, cube, octahedron, dodecahedron and icosahedron, with 44, 66, 88, 1212 and 2020 sides, respectively. In DnD terminology, these dice are usually called d4, d6, d8, d12 and d20.

As a dungeon master, you are currently designing a campaign for your group of players. In the final battle of this campaign, the players need to roll a combination of multiple dice with varying numbers of sides, and the action of the enemy is determined by the sum of the numbers on the dice that were rolled. For balancing purposes, you want to sort these sums based on how likely they are to occur, so that you can assign appropriate events to each of them.

Given the number of dice of each type, and assuming the sides of each die are numbered from 11 to the number of sides, find all possible sums of dice rolls and output them sorted by non-increasing probability.

입력

The input consists of:

  • One line with five integers tt, cc, oo, dd and ii, (0≤t,c,o,d,i≤100 \le t, c, o, d, i \le 10), giving the number of tetrahedra, cubes, octahedra, dodecahedra and icosahedra among the dice that are rolled. There is always at least one die, that is t+c+o+d+i≥1t+c+o+d+i \ge 1.

출력

Output all possible sums, ordered from most likely to least likely. If two sums occur with the same probability, then those sums may be printed in any relative order.

예제3

  1. 예제 1

    입력
    1 1 1 0 0
    
    예상 출력
    11 10 9 12 8 13 14 7 15 6 5 16 17 4 18 3
    
  2. 예제 2

    입력
    2 0 0 1 0
    
    예상 출력
    9 14 12 11 10 13 15 8 16 7 6 17 5 18 4 19 3 20
    
  3. 예제 3

    입력
    0 0 0 0 1
    
    예상 출력
    10 3 9 8 14 13 11 7 6 12 20 4 15 5 16 1 2 19 17 18