快速乘大法可以防a*b%p爆longlong,在a%p*b%m还有可能爆longlong时,快速乘吧!!!!少年!!!!
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
long long quick_mul(long long x,long long y,long long p)
{
if (y==0) return 0;
if (y==1) return x%p;
long long re;
re=quick_mul(x,y>>1,p);
if ((y&1)==1) return (re+re+x)%p;
else return (re+re)%p;
}
int main()
{
long long x=1000000000,y=1000000000,p=10;
printf("%I64d
",quick_mul(x,y,p));
return 0;
}