CCC '06 J2 - Roll the Dice


Submit solution

Points: 1
Time limit: 2.0s
Memory limit: 256M

Problem type
Allowed languages
C++, Python
Canadian Computing Competition: 2006 Stage 1, Junior #2

Diana is playing a game with two dice. One die has \(m\) sides labelled \(1, 2, 3, \dots, m\) .

The other die has \(n\) sides labelled \(1, 2, 3, \dots, n\) .

Write a program to determine how many ways can she roll the dice to get the sum \(10\) .

For example, when the first die has 6 sides and the second die has 8 sides, there are 5 ways to get the sum \(10\) :

  • 2 + 8 = 10
  • 3 + 7 = 10
  • 4 + 6 = 10
  • 5 + 5 = 10
  • 6 + 4 = 10

Input

The input is given as two integers. First, the user will enter in the number \(m\) \((1 \le m \le 1000)\) .

Second, the user will enter the number \(n\) \((1 \le n \le 1000)\) .

Output

The program prints out the number of ways \(10\) may be rolled on these two dice. Note that in the output, the word way should be used if there is only one way to achieve the sum of \(10\) ; otherwise, the word ways should be used in the output. That is, if there is only one way to get the sum \(10\) , the output should be:

There is 1 way to get the sum 10.

Sample Input 1

6
8

Sample Output 1

There are 5 ways to get the sum 10.

Sample Input 2

12
4

Sample Output 2

There are 4 ways to get the sum 10.

Comments

There are no comments at the moment.