#141. 掷骰子求和与特殊规则

    ID: 141 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatLogic-1gesp1条件结构数学基础

掷骰子求和与特殊规则

Dice Roll Sum

Background

In a casual board game, players roll two six-sided dice to determine their actions. To add more fun to the game, sometimes special rules are introduced.

Problem Description

Given the values of two 6-sided dice rolls, each in the range 11 to 66. Return their sum. However, if noDoubles is true, and the two dice show the same value, increment one die to the next value, wrapping around to 11 if its value was 66.

Input Format

Input is given from standard input in the following format.

die1 die2 noDoubles

die1 and die2 are the values of the two dice, and noDoubles is a boolean value (true or false).

Output Format

Output is printed to standard output in the following format.

sum

The adjusted sum of the two dice rolls.

Sample

2 3 true
5
3 3 true
7
3 3 false
6

Sample Explanation

  • Sample 1: Dice values are 22 and 33. Since they are not doubles, the noDoubles rule does not apply. The sum is 2+3=52 + 3 = 5.
  • Sample 2: Both dice values are 33. Since they are doubles and noDoubles is true, we increment one die's value from 33 to 44. The sum is 3+4=73 + 4 = 7.
  • Sample 3: Both dice values are 33. Although they are doubles, noDoubles is false, so the special rule is not applied. The sum is 3+3=63 + 3 = 6.

Constraints

  • 1extdie1,extdie261 \le ext{die1}, ext{die2} \le 6
  • noDoubles is true or false.
  • Time limit: 1 second
  • Memory limit: 1024 KB