Cod sursa(job #2482648)
Utilizator | Data | 28 octombrie 2019 18:15:09 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int mod = 1999999973;
int lg(int n, int p)
{
int r = 1;
while(p)
{
if(p & 1)
r = (1LL * r * n) % mod;
n = (1LL*n*n) % mod;
p /= 2;
}
return r;
}
int main()
{
int n, p;
fin >> n >> p;
fout << lg(n, p);
return 0;
}