eolymp
bolt
Try our new interface for solving problems
Problems

Sum of powers 2

Sum of powers 2

Find the sum $(1^1 + 2^2 + 3^3 + .... + n^n)~mod~m$. \InputFile Two positive integers $n$ and $m~(n, m \le 10^6)$. \OutputFile Print the value of the sum modulo $m$.
Time limit 2 seconds
Memory limit 128 MiB
Input example #1
4 100
Output example #1
88
Author Michael Medvedev