快速幂讲解
import java.util.*;
public class Main {
private static int n, m, k, x;
private static long qmi(long a, int b, int p) {
long res = 1 % p;
while (b > 0) {
if ((b & 1) != 0) {
res = (long)res * a % p;
}
a = (long)a * a % p;
b >>= 1;
}
return res;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
m = sc.nextInt();
k = sc.nextInt();
x = sc.nextInt();
System.out.println((x + (long)qmi(10, k, n) * m) % n);
}
}
标签:int,res,long,nextInt,static,转圈,二十四,sc,504
From: https://www.cnblogs.com/he0707/p/18112173/lanqiaobei24