시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 256 MB | 61 | 45 | 31 | 75.610% |
A sequence of digits usually represents a number, but we may define an alternative interpretation. In this problem we define a new interpretation with the order relation ≺ among the digit sequences of the same length defined below.
Let s be a sequence of n digits, d1d2···dn, where each di (1 ≤ i ≤ n) is one of 0, 1, . . . , and 9. Let sum(s), prod(s), and int(s) be as follows:
int(s) is the integer the digit sequence s represents with normal decimal interpretation.
Let s1 and s2 be sequences of the same number of digits. Then s1 ≺ s2 (s1 is less than s2) is satisfied if and only if one of the following conditions is satisfied.
For 2-digit sequences, for instance, the following relations are satisfied.
00 ≺ 01 ≺ 10 ≺ 02 ≺ 20 ≺ 11 ≺ 03 ≺ 30 ≺ 12 ≺ 21 ≺ · · · ≺ 89 ≺ 98 ≺ 99
Your task is, given an n-digit sequence s, to count up the number of n-digit sequences that are less than s in the order ≺ defined above.
The input consists of a single test case in a line.
d1d2···dn
n is a positive integer at most 14. Each of d1, d2, . . . , and dn is a digit.
Print the number of the n-digit sequences less than d1d2···dn in the order defined above.
20
4
020
5
118
245
11111111111111
40073759
99777222222211
23733362467675
ICPC > Regionals > Asia Pacific > Japan > Asia Regional Contest 2015 in Tsukuba E번