#P8350. [SDOI/SXOI2022] 进制转换
[SDOI/SXOI2022] 进制转换
Problem Description
When Little D was two years old, he already learned base conversion.
So he wants to ask you: for all numbers between , what are the sums of digits of this number in binary and ternary, respectively.
For , let the sums of digits in binary and ternary be and , respectively. For example, for , its binary representation is , and its ternary representation is , so and are both .
Little D wants to know whether you can really compute base conversions correctly for all numbers from to , so he asks what
is. Since the answer is very large, output the result modulo .
Input Format
There is only one line with four integers, in order: .
Output Format
Output one line with one integer, representing the answer.
123456 12345 234567 3456789
664963464
1234567891 123 1 12345
517823355
9876543210987 1284916 83759265 128478129
115945104
Hint
Constraints
This problem has test points.
- For test points , .
- For test points , .
- For test points , .
- For test points , .
- For test points , .
For all test points, , .
Translated by ChatGPT 5