快速加类似于快速幂运算
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long LL;
//实现快速加
LL qadd(LL a, LL b, LL c)
{
LL res = 0;
while (b) {
if (b & 1) {
res =(res+a)%c;
}
a = (a+a) % c;
b >>= 1;
}
return res;
}
int main()
{
LL a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
printf("%lld", qadd(a, b, c));
system("pause");
return 0;
}