Cod sursa(job #2377738)
Utilizator | Data | 11 martie 2019 00:34:39 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int ridicare(int n,int p)
{
const int h=1999999973;
int r=1;
while(p!=0){
if(p%2==1)r=(1LL*r*n)%h;
/*else{
if(p%3==2)r=(1LL*((1LL*r*n)%h)
}*/
n=(1LL*n*n)%h;
p=p/2;
}
return r;
}
int main()
{
int p,n;
f>>n>>p;
g<<ridicare(n,p);
return 0;
}