Your Rank is Pure (Small)
Time limit5sMemory limit512 MB
Count subsets of 2 to n containing n whose repeated rank mapping stays inside the set until it reaches 1, modulo 100003.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics
- Solved
- No attempts yet
Problem
Pontius: You know, I like this number 127, I don't know why.
Woland: Well, that is an object so pure. You know the prime numbers.
Pontius: Surely I do. Those are the objects our ancient masters possessed hundreds of years ago. Oh, yes, why then? 127 is indeed a prime number as I was told.
Woland: Not... only... that. 127 is the 31st prime number; then, 31 is itself a prime, it is the 11th; and 11 is the 5th; 5 is the 3rd; 3, you know, is the second; and finally 2 is the 1st.
Pontius: Heh, that is indeed... purely prime.
The game runs on a set of positive integers. For an element of , sort the elements of in increasing order and count positions from 1. The position of in that order is the rank of , written .
An element of is pure with respect to when the sequence that starts at and repeatedly replaces the current value by its rank in reaches 1 after finitely many steps, and every value it visits before reaching 1 belongs to . The number 1 never belongs to .
You are given . Count the subsets of for which is pure with respect to . The count can be large, so print it modulo .
Input
The first line contains the number of test cases . Each of the next lines contains one integer .
Limits
Output
For each test case, print one line of the form Case #x: y, where x is the test case number starting from 1 and y is the count described above.