Cod sursa(job #2696560)
Utilizator | Data | 16 ianuarie 2021 10:03:57 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.28 kb |
#include <iostream>
#include <fstream>
using namespace std;
fstream f("lgput.in");
ofstream g("lgput.out");
int n,p,r;
long long mod=1999999973;
int main()
{f>>n>>p;
r=1;
while(p>1)
{
if(p%2==1)r=(1LL* r*n)%mod;
n=(1LL *n*n)%mod;
p=p/2;
}
g<<n*r;
return 0;
}