Cod sursa(job #2060454)
Utilizator | Data | 8 noiembrie 2017 11:57:07 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <fstream>
using namespace std;
ifstream f1("lgput.in");
ofstream f2("lgput.out");
int main()
{
long long int n,p,sol=1;
f1>>n>>p;
while(p>0)
{ if(p%2==1)
sol=(sol*n)%1999999973;
n=(n*n)%1999999973;
p=p/2;
}
f2<<sol;
f1.close();
f2.close();
return 0;
}