用快速幂实现x^y的个位
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
long long fun(long long x, long long y, int z) {
long long sum = 1;
x=x%z;
while (y>0) {
if (y % 2 == 1) {
sum = (sum*x) % z;
y=y-1;
} else {
y = y / 2;
x=(x*x) % z;//让x翻倍
}
}
return sum;
}