用户输出
25646167
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#69143 | #110. czq的模法数列 | Accepted | 100 | 641 ms | 11392 K | Java / 1.3 K | zaiz7 | 2022-05-02 11:31:30 |
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) {
Read in = new Read();
int n = in.nextInt(), q = in.nextInt(), p = in.nextInt();
long res = 1;
long a0 = 1;
for (int i = 2; i <= n; i++) {
a0 = (a0 * (q % p)) % p;
res += a0;
res %= p;
}
System.out.println(res);
}
static class Read {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while (!st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
int[] readArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
}
用户输出
192041748
系统信息
Exited with return code 0
用户输出
917164423
系统信息
Exited with return code 0
用户输出
626438667
系统信息
Exited with return code 0