Cod sursa(job #1546890)
Utilizator | Data | 8 decembrie 2015 20:23:02 | |
---|---|---|---|
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;
int main()
{
unsigned long long int n, p, x=1;
ifstream f("lgput.in");
f>>n>>p;
f.close();
while(p)
{
if(p%2==1)
{
x=(x*n)%1999999973;
p--;
}
n=(n*n)%1999999973;
p=p/2;
}
ofstream o("lgput.out");
o<<x;
o.close();
return 0;
}