StatementStatement languageEnglishexpand_more한국어English日本語简体中文You are given positive integers A,D,NA,D,NA,D,N and a prime number ppp. Compute the following value: (∑i=0N−1(A+iD)A+iD) mod p\left(\sum_{i=0}^{N-1}(A+iD)^{A+iD}\right)\bmod p(i=0∑N−1(A+iD)InputThe input is given in the following format:A D N pA\ D\ N\ pA D N pOutputPrint the computed value on one line.Constraints 1≤A,D,N≤10181\le A,D,N\le 10^{18}1≤A,D,N≤1018. 2≤p≤1062\le p\le 10^62≤. Subtasks#ScoreConstraints125N≤300 000N\le 300\,000N≤300000.230p≤1 000p\le 1\,000p≤1000.345No additional constraints.SamplesSample 1InputCopy1 1 5 7OutputCopy4The five terms are 11,22,33,44,551^1,2^2,3^3,4^4,5^511,22,33,4. Their sum has remainder modulo .Show tags