Cod sursa(job #2200938)
| Utilizator | Data | 2 mai 2018 21:47:21 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.52 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f ("lgput.in");
ofstream g ("lgput.out");
const int mod = 1999999973;
typedef long long ll;
ll lgPow(ll b, ll e) {
ll ans = 1;
ll aux = b;
for(int i = 1; i <= e; i *= 2) {
if(i & e) {
ans = (ans * aux) % mod;
}
aux *= aux;
aux %= mod;
}
return ans;
}
int main()
{
ll n, p;
f >> n >> p;
g << lgPow(n, p) << '\n';
f.close();
g.close();
return 0;
}
