Cod sursa(job #2125544)
Utilizator | Data | 8 februarie 2018 15:49:12 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
long long n,p,mod=1999999973;
fin>>n>>p;
int sol=1;
while(p>0)
{
if(p%2==1)
sol=((sol%mod)*(n%mod))%mod;
n=n*n%mod;
p=p/2;
}
fout<<sol%mod;
}