Cod sursa(job #2816864)
Utilizator | Data | 12 decembrie 2021 12:56:29 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1999999973;
long long put(long long base, int exp) {
long long ans = 1;
while (exp) {
if ((exp & 1))
ans = ans * base % MOD;
base = base * base % MOD;
exp >>= 1;
}
return ans;
}
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int n,p;
fin >> n >> p;
fout << put(n, p);
return 0;
}