#include
#include<math.h>
using namespace std;
int main() {
long a,b,c;
cin>>a>>b>>c;
long res=pow(a,b);
long mod=res%c;
cout<<mod;
return 0;
}
is there any issue in logic ?
#include
#include<math.h>
using namespace std;
int main() {
long a,b,c;
cin>>a>>b>>c;
long res=pow(a,b);
long mod=res%c;
cout<<mod;
return 0;
}
is there any issue in logic ?
Hey @jsunidhi
pow will result in overflow
so u have to make ur own pow function and take modulo in intermediate steps
Incase u don’t know
(a+b)%x == (a%x +b%x)%x and this can be extended to any number of variables