1
0
Fork 0
projecteuler/38.txt

28 lines
1.2 KiB
Plaintext

Given a certain tuple (1, 2, ..., n), only a certain range of integers i are allowed to produce a nine-digit concatenation.
(1, 2): 1 * _ _ _ _ = _ _ _ _
2 * _ _ _ _ = _ _ _ _ _
5000 <= i <= 9999
(1, 2, 3): 1 * _ _ _ = _ _ _
2 * _ _ _ = _ _ _
3 * _ _ _ = _ _ _
100 <= i <= 333
(1, 2, 3, 4): 1 * _ _ = _ _
2 * _ _ = _ _
3 * _ _ = _ _
4 * _ _ = _ _ _
25 <= i <= 33
(1, 2, 3, 4, 5): 1 * _ = _
2 * _ = _ _
3 * _ = _ _
4 * _ = _ _
5 * _ = _ _
5 <= i <= 9
(1, 2, 3, 4, 5, 6): 1 * _ = _
2 * _ = _
3 * _ = _
4 * _ = _ _
5 * _ = _ _
6 * _ = _ _
i == 3
In the given example, 9 x (1, 2, 3, 4, 5) = 918273645. Then to produce a larger concatenation, with the given restrictions on i, we can only use i x (1, 2), where 9183 <= i <= 9876. Then only 693 values of i need to be tested.