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

34413번 - Rolling The Dice 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB54413271.111%

문제

In Dungeons and Dragons, we use dice rolls very often to determine which actions succeed and which fail. There are many different dice with varying numbers of sides so we have a shorthand for representing different rolls. A single roll is written as "d#," with the "#" representing the number of sides on the die. If you need to roll multiple dice of the same type, there will be a number before the "d". For example, if you are required to roll 4d6, you would roll four six-sided dice and add the results together. There will also be a + after the notation, meaning that you add that number to the total results of the dice (not to each individual die rolled).

Higher numbers are better, and I want to make my character as powerful as possible, so I need to know what number I'll get on average for different rolls. It's relatively simple to do statistics on dice because every value has an equal chance of being rolled. If you average the minimum value and the maximum value of the roll, it will give you the value that you would get on average if you rolled it many times. For example, the roll 2d6+5 has a minimum value of 7ドル$ if you roll two 1s and a maximum value of 17ドル$ if you roll two 6ドル$'s which gives an average of 12ドル$ overall (for 2d6+5). Given the notation for a roll, find the average value of that roll.

입력

The input will be a single line in the form of "XdY+Z". X, Y, and Z are all integers and will fall within the same range, 1ドル \le X, Y, Z \le 100$.

출력

Your program needs to output the average value that you would expect for the given roll values.

제한

예제 입력 1

2d6+5

예제 출력 1

12

예제 입력 2

1d10+12

예제 출력 2

17.5

노트

출처

School > CS@Mines > CS@Mines HSPC 2021 C번

  • 문제를 만든 사람: Adam Sandstedt
(追記) (追記ここまで)

출처

대학교 대회

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

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