Given two integers $N$ and $M$. Calculate $N^N\pmod M$. Input format The input contains two integers $N$ and $M$ ($1 \le 10^9$, $2 \le M \le 10^9$). Output format Print one integer - the value of $N^N\pmod M$. Sample 1 Input
5/27/2021Given three integers $a$, $n$ and $m$. Calculate the value $\frac{1}{a} + \frac{2}{a^2} + \frac{3}{a^3} \cdots + \frac{n}{a^n} \pmod{m}$. Input format The input contains three integers $a$, $n$ and $m$ ($1 \le a \le 10^9$, $2 \le n \le 10^6$, $2 \le m \le 10^9 + 9$ ). Output format Print one integer - the value of $1/a + 2/a^2 + 3/a^3 \cdots + n/a^n \pmod{m}$. If at least one of divisions cannot be done, print $-1$ instead. Sample 1 Input
5/27/2021Given four non-zero integers $a$, $b$, $c$ and $d$. Calculate $\frac{ad+bc}{bd} \pmod{10^9+7}$. Input format The input contains four integers $a$, $b$, $c$ and $d$ ($1 \le a, b, c, d \le 10^9$). Output format Print one integer - the value of $\frac{ad+bc}{bd} \pmod{10^9+7}$. Sample 1 Input
5/27/2021Given two integers $a$ and $b$. Calculate $a^2 - b^2$ modulo ($10^6+7$). Input format Two non-negative integers $a$ and $b$ not exceeding $10^5$. Output format Print one integer - the value of $a^2 - b^2$ modulo ($10^6+7$). Sample 1 Input
5/24/2021or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up