hii .. i have been trying this problem . Though it passed the easy test cases , it does not clear the hard cases though
My code looks like :
// include libraries
#define BIGINTBASE 10000
class BigInt {
// BigInt functions ...
};
BigInt mod(BigInt a,BigInt b,BigInt c)
{
BigInt x=1,y=a;
while(b > 0){
if(b%2 == 1){
x=(x*y)%c;
}
y = (y*y)%c;
b /= 2;
}
return x%c;
}
int main()
{
int test;scanf("%d",&test);
while(test--){
string x,y,n;
cin>>x>>y>>n;
BigInt X=x;
BigInt Y=y;
BigInt N=n;
BigInt ret=mod(X,Y,N);
cout<<ret<<endl;
}
return 0;
}
My base is 10000 . Is this too slow to get accpted for this problem ?
This is not the first problem I solved with my BigInt class . I solved EQU2, SUBST1,CFRAC2 using the same BigInt class .