Cod sursa(job #2765956)
Utilizator | Data | 30 iulie 2021 15:31:34 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int mod = 1999999973;
int n, p;
int pow(int x, int p)
{
int aux = 1;
while(p)
{
if(p & 1)
{
aux = (1LL * aux * x) % mod;
}
x = (1LL * x * x) % mod;
p /= 2;
}
return aux;
}
int main()
{
fin >> n >> p;
fout << pow(n, p);
return 0;
}