The powerful sum
Let us calculate the sum of k-th powers of natural numbers from 1 to n. As the result can be quite large, output the result modulo some integer p. Input First tOutput For each test case, output the value: (1k+2k+...+nk) mod p. ### Sample Test Cases **Sample 1** Input: ``` 4 10 1 1000000 10 2 1000000 10 3 1000000 10 4 1000000 ``` Output: ``` 55 385 3025 25333 ```
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start