Cod sursa(job #2375288)
Utilizator | Data | 8 martie 2019 00:07:15 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 40 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
#include <cstring>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n,p,x,nr;
int main()
{
fin>>n>>p;
nr=(n*n)%mod;x=2;
while(x*2<p)
{
nr=(nr*nr)%mod;
x=x*2;
}
while(x<p)
{
nr=(nr*n)%mod;
x++;
}
fout<<nr;
return 0;
}