test cases are not passing .
code–
#include
using namespace std;
int main() {
long long int a,b,c;
cin>>a>>b>>c;
long long int x=(a^b)%c;
cout<<x;
return 0;
}
Modular exponential test cases not passing
The failure of code is due to the following reason:
The maximum value a and b can have is 100000.
What you are are doing is a^b i.e. 100000^100000.
Is there any datatype available to store this big(infinitely big) value?
No, is the answer.
This, is the reason you are getting wrong output. If you want to verify this, then I would suggest you to print ans and see what it print.
Think of a different way to calculate modular exponential.
Hint: study about exp. by squaring method algorithm.
Refer the below mentioned link for details:
https://www.google.com/url?sa=i&source=web&cd=&ved=2ahUKEwiW37bntJTjAhXXWisKHU6SAswQzPwBegQIARAC&url=https%3A%2F%2Fwww.geeksforgeeks.org%2Fexponential-squaring-fast-modulo-multiplication%2F&psig=AOvVaw1vw3oDqn1bMtovjRL8iMdC&ust=1562094281766744
If you still have doubts, feel free to ask.
I am marking this doubt as resolved as you have not replied to this thread for 5 day.
In case, you still have some doubts regarding the same problem, you can reopen this doubt.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.