-->
当前位置:首页 > 题库

PROGRAMMING:Guess the number (Ningbo primary school, 2012)

Luz5年前 (2021-05-10)题库508
Weiwei is playing the game of guessing numbers recently, and now she wants you to play it. What are the rules of the number guessing game
So, tell you a positive integer n (2 < = n < = 11), and then Weiwei will think of a number string composed of N numbers
(the first bits of the string may be 0). Weiwei will randomly arrange the number of N digits, which may produce n! N
Number of digits( n!= one × two × three × four × five ×……× n,n! Read "n factorial")
For example, if Weiwei thinks of a three digit ABC, it will produce six three digits, which are
abc,acb,bac,bca,cab,cba
Then Weiwei will take this n! If there are several zeros at the beginning of the first digit of a number, these zeros will be rounded off. If there is a number of "0123", then the value added to s when summing is 123). She will tell you the value of sum s minus the number in her mind. Please guess the number in Weiwei's mind.
###Input format:
The input contains two lines. The first line is an integer n (meaning as described above), and the second line is a positive integer
Integer s for n! The sum of the numbers minus the number in Weiwei's heart.
###Output format:
Output a total of a line of a number, indicating that the taste of the heart of the n-digit (test data to ensure existence)
Unique solution). If there are several zeros at the beginning of the first digit of the number, these zeros must also be output (see example 3 for details).
###Input sample 1:
```in
three
one thousand two hundred and nine
```
###Output sample 1:
```out
one hundred and twenty-three
```
[explanation of input and output example 1]
If Weiwei thinks 123, then s = 123 + 132 + 213 + 231 + 312 + 321-123 = 1209 meets the requirements.
###Input sample 2:
```in
four
forty-five thousand four hundred and forty
```
###Output sample 2:
```out
one thousand two hundred and twenty-two
```
[input and output example 2 explanation]
If Weiwei is thinking of 1222, then
S=1222+1222+1222+1222+1222+1222+2122+2122+2122+2122+2122+2122+2212+2212+2212+22
12 + 2212 + 2212 + + 2221 + 2221 + 2221 + 2221 + 2221 + 2221 + 2221-1222 = 45440 meets the requirements.
###Input sample 3:
```in
two
ninety
```
###Output sample 3:
```out
09
```
[input and output example 3 explanation]
If Weiwei thinks 09, then s = 09 + 90-09 = 9 + 90-9 = 90, which meets the requirements.
[data range]
For 20% of the data n≤3
For 60% of the data n≤5
For 100% data 2≤n≤11 ,0≤S≤1018







answer:If there is no answer, please comment