Cod sursa(job #2616254)
Utilizator | Data | 17 mai 2020 18:54:07 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
#define MOD 1999999973
int lgput(int n, int p)
{
int rez = 1;
while(p)
{
if(p & 1)
rez = (1LL * rez * n) % MOD;
n = (1LL * n * n) % MOD;
p /= 2;
}
return rez;
}
int main()
{
ios_base::sync_with_stdio(0);
fin.tie(0);
unsigned long long n, p;
fin >> n >> p;
fout << lgput(n, p);
return 0;
}