@aman212yadav find find out the 500 000 prime number then chance the pos of that prime number.
In that case we have to at least generate the all the prime number then we are able to find out?
Modular Exponentian
@aman212yadav
The 500,000th prime is 7,368,787. then we need to add one .
So is there any methods or tricks to findout ?
@aman212yadav can we use the dynamic array
I am getting the segment fault.
As said i am implement in that way
@aman212yadav I got the answer. One think i want to know int can accomdate the 800000 digits easy so why long long ?
And another think suppose n number is large if we n*n it cann’t be accomdate in longlong when what should we do in that case?
1<=n<=5000000 .
getting TLE ? working fine for5,00,000
800000* 800000 can exceed the range of int thats why long long
@Vikaspal
see first i*i will be performed and then value is assigned to long long j .
and incase i is of int type and value in it is big then overlflow will occure
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.
#include
using namespace std;
int main() {
int a,b,c;
cin>> a>>b>>c;
a= a%c;
long long product=1;
while(b--){
product*= a;
product= product%c;
}
cout<< product%c;
}
This will work fine