atcoder#ARC153E. [ARC153E] Deque Minimization
[ARC153E] Deque Minimization
Score : points
Problem Statement
For a positive integer none of whose digits is , consider obtaining a positive integer as follows.
- Initialize as an empty string.
- Let be the number of digits in . For in this order, do the following: insert the -th character in the decimal notation of at the beginning or end of .
- Let be the positive integer represented by the string .
Let denote the minimum positive integer that can be obtained from in this way.
You are given a positive integer none of whose digits is . Print the number, modulo , of positive integers none of whose digits is such that .
Constraints
- is a positive integer none of whose digits is .
Input
The input is given from Standard Input in the following format:
Output
Print the number, modulo , of positive integers none of whose digits is such that .
1332
3
Three integers, , , and , satisfy the conditions.
3312
0
12234433442
153