Cod sursa(job #2775600)
| Utilizator | Data | 16 septembrie 2021 15:10:00 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include <bits/stdc++.h>
#define mod 1999999973
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
void usain_bolt()
{
ios::sync_with_stdio(false);
fin.tie(0);
}
long long lgput(long long a, long long b)
{
long long sol = 1;
while(b != 0) {
if(b & 1) {
sol = (sol * a) % mod;
}
a = (a * a) % mod;
b >>= 1;
}
return sol;
}
int main()
{
usain_bolt();
long long n, p;
fin >> n >> p;
fout << lgput(n, p);
return 0;
}
