Cod sursa(job #2285903)
Utilizator | Data | 19 noiembrie 2018 14:58:00 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream("lgput.in");
ofstream("lgput.out");
unsigned long long n, p, a=1,rest=1999999973;
cin >> n >> p;
while(p>0)
{
if(p%2==1)
a=a%rest*n%rest;
n=n%rest*n%rest;
p=p%rest/2;
}
cout << a%rest;
return 0;
}