Cod sursa(job #1973095)
Utilizator | Data | 24 aprilie 2017 14:12:22 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
long long x,n,p;
fin>>x>>n;
p=x;
n--;
while(n>=1)
{
if(n%2==1)
{
p=p*x%1999999973;
n--;
}
else {x=x*x%1999999973;n=n/2;}
}
fout<<p%1999999973;
return 0;
}