시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 25 | 24 | 23 | 95.833% |
Peter is a math teacher at an elementary school. To familiarize students with three basic arithmetic operations plus (+), minus (−) and times (×), he gives a simple arithmetic puzzle as homework. The puzzle is that you are given 4 digits, and you are told to build as many non-negative integers as possible using just those 4 digits and at least one of the three basic arithmetic operations. For example, you are given 1,1,2,1 as the digits, and then you can build 32 non-negative integers as Table 1.
Table 1: Numbers made by 1,1,2,1.
0 = 2 − 1 − 1 × 1 | 1 = 2 + 1 − 1 − 1 | 2 = 2 + 1 − 1 × 1 | 3 = 2 + 1 + 1 − 1 | 4 = 2 + 1 + 1 × 1 | 5 = 2 + 1 + 1 + 1 | 8 = 11 − 2 − 1 | 9 = 11 − 2 × 1 |
10 = 12 − 1 − 1 | 11 = 12 − 1 × 1 | 12 = 12 + 1 − 1 | 13 = 12 + 1 × 1 | 14 = 12 + 1 + 1 | 19 = 21 − 1 − 1 | 20 = 21 − 1 × 1 | 21 = 21 + 1 − 1 |
22 = 21 + 1 × 1 | 23 = 21 + 1 + 1 | 32 = 21 + 11 | 109 = 111 − 2 | 111 = 112 − 1 | 112 = 112 × 1 | 113 = 112 + 1 | 120 = 121 − 1 |
121 = 121 × 1 | 122 = 121 + 1 | 132 = 12 × 11 | 210 = 211 − 1 | 211 = 211 × 1 | 212 = 211 + 1 | 222 = 111 × 2 | 231 = 21 × 11 |
To check whether the student’s answer includes all possible integers, Peter needs to know the total number of non-negative integers that can be built for the puzzle. Please write a program to help Peter compute the total number.
The input file contains 4 integers separated by a space in a line, which indicates the given digits.
Output the total number of non-negative integers that can be built.
1 1 1 1
15
1 1 2 1
32