The Expression from the Numbers
This is enough known task from mathematics: how can you with help by 5 numbers of 2, signs of arithmetic actions and brackets to write down a number 7?
It can be done such as (2+2*2)+2/2, so 22/2-2*2 or as 2*(2+2)–2/2.
And you have to know what least natural number M can not be given such method, if you can use N numbers of the number D?
Note: A division is executed entirely.
Specifications
Input
The natural numbers N and D are written down in the one line of file (1 ≤ N ≤ 7, 1 ≤ D ≤ 9).
Output
You have to write the number M – the least number which can not be given as arithmetic expression if you can use N numbers of the number D.
Problem information
Time Limit: 1 secondsMemory Limit: 64 MB
Balls for the passed test: 5.88235
Complexity: 57% 13/30
Example
Example input3 2 |
Example output4 |
| ← Industrious bees | Problems | The Way Home → |
