#P15571. [USACO26FEB] Strange Function B
[USACO26FEB] Strange Function B
题目描述
For all positive integers , the function is defined as follows:
If has any digits that aren't or , for each digit of , set it to if it is odd or otherwise, and return . Otherwise, return .
Given a value of (), find how many times needs to be applied to until reaches . As this number might be very large, output its remainder when divided by .
输入格式
The first line contains (), the number of independent tests.
The next lines each contain a positive integer consisting solely of the digits 0-9, with no leading zeros.
It is guaranteed that the total number of digits in all input integers does not exceed .
输出格式
For each test case, output the remainder of the number of times when divided by on a separate line.
2
24680
210
1
4
1
1234567890123456789012345678901234567890
511620083
提示
Sample 1 Explanation
First test: becomes zero after one operation.
Second test:
SCORING:
- Inputs 3-5: ,
- Inputs 6-7:
- Inputs 8-9:
- Inputs 10-12: No additional constraints.
Problem credits: Aiden Bai