F.A.Qs Home Discuss ProblemSet Status Ranklist Contest 入门OJ LoginRegister
Problem 5543. -- 幂次求和

5543: 幂次求和

Time Limit: 50 Sec  Memory Limit: 512 MB
Submit: 39  Solved: 2
[Submit][Status][Discuss]

Description

m^k+(m+1)^k+(m+2)^k+......+n^k模p的余数(p是质数)

Input

一行包含4个正整数k,n,m,p

Output

如题

Sample Input

4 2 2 97

Sample Output

16

HINT

K<=10^12

N,M,P<=10^12

N-M<=5000

Source

[Submit][Status][Discuss]

HOME Back