#P2480. [SDOI2010] 古代猪文

    ID: 1494 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数学2010各省省选山东O2优化素数判断,质数,筛法中国剩余定理,CRT

[SDOI2010] 古代猪文

Description

The civilization of the Pig Kingdom has a long history and great depth.

In the library of Big Fat Pig School, iPig learned from reference materials that the total number of characters in the ancient pig script was nn. Of course, if a language has many characters, its dictionary will be correspondingly large. The Pig King of that time considered that if a dictionary were compiled, its scale might far exceed the Kangxi Dictionary, and the manpower and material resources required would be immeasurable. After careful consideration, he did not undertake this labor- and resource-intensive project. Naturally, the script of the Pig Kingdom was later simplified over history by removing some uncommon characters.

iPig plans to study the pig script from a certain dynasty in ancient times. According to relevant documents, the characters used in that dynasty happened to be exactly 1/k1/k of those in the distant past, where kk is a positive divisor of nn (it can be 11 or nn). However, exactly which 1/k1/k was used, and what kk was, can no longer be verified due to the remoteness of history.

iPig believes that as long as it matches the documents, every knk \mid n is possible. He will consider all possible kk. Clearly, when kk is fixed, the number of characters in that dynasty’s script is n/kn/k. However, the number of ways to retain n/kn/k characters out of nn is also quite large. iPig estimates that if the total number of cases over all possible kk sums to pp, then the cost of his research on the ancient script will be gpg^p.

He now wants to know the cost for the Pig Kingdom to study the ancient script. Since iPig thinks this number may be astronomical, you only need to tell him the remainder of the answer modulo 999911659999911659.

Input Format

One line containing two positive integers n,gn, g.

Output Format

Output one line containing a single integer representing the answer.

4 2
2048

Hint

  • Constraints
    • For 10%10\% of the testdata, 1n501 \le n \le 50.
    • For 20%20\% of the testdata, 1n10001 \le n \le 1000.
    • For 40%40\% of the testdata, 1n1051 \le n \le 10^5.
    • For 100%100\% of the testdata, 1n,g1091 \le n, g \le 10^9.

Translated by ChatGPT 5