Cod sursa(job #1714000)
Utilizator | Data | 7 iunie 2016 08:26:49 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
int a,b;
long long f (long long n, long long p)
{
long long aux = 1;
while(p != 0) {
if(p % 2 == 1) aux = (aux * n) % 1999999973;
n = (n * n) % 1999999973;
p /= 2;
}
return aux;
}
int main()
{
long long n, p;
in >> n >> p;
out << f (n, p);
return 0;
}