TouchStone
  Please Login
Login Sign Up
 Homepage  Problem Set  Examinations  Submissions  Discussions  Statistics
  • Home
  • Problem Set
  • P4399
  • Problem
  • P4399自然数幂求和 | linux对拍
    Limits : Time Limit : - MS   Memory Limit : 524288 KB
    Judgment Tips : 3s,512MB
    Description

    输入 \(n,k,p\) ,计算 $1^k+2^k+\cdots+n^k$ 的值 \(\bmod p\)

    \[ \begin{align} n&\leq 10^{10^6}\\ k&\leq 3\times 10^6\\ p&\in \left[10^9,\ 10^9+10^7\right] \cap \texttt{Prime} \end{align} \]

    linux版本

    Input Format

    三个整数 \(n,k,p\)

    Output Format

    一个整数答案。

    Sample Input 1

    5 3 1000000007

    Sample Output 1

    225

    Sample Input 2

    15 3 1000000007

    Sample Output 2

    14400

    Sample Input 3

    15 10 1000000007

    Sample Output 3

    532660458

    Sample Input 4

    2333 101 1000000007

    Sample Output 4

    867715963

    Sample Input 5

    111222333444555666777888999888777666555444333222111222333444555666777888999 123456 1000000007

    Sample Output 5

    585742209