Cod sursa(job #1622569)
| Utilizator | Data | 1 martie 2016 12:25:42 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1999999973;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll lgput(ll a, ll b) {
ll base = a;
ll sol = 1;
for(int k = 0; (1 << k) <= b; k++) {
if(((1 << k) & b) > 0)
sol = (sol * base) % MOD;
base = (base * base) % MOD;
}
return sol;
}
int main() {
ll a, b;
fin >> a >> b;
fout << lgput(a, b) << "\n";
}
