Cod sursa(job #1974364)
| Utilizator | Data | 27 aprilie 2017 13:55:56 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1999999973;
long long lgput(long long A, long long B)
{
long long x0 = A, x1 = 1;
while(B)
if(B & 1) {
x1 = (x1 * x0) % MOD;
B ^= 1;
}
else {
x0 = (x0 * x0) % MOD;
B >>= 1;
}
return x1;
}
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
long long a,b;
cin >> a >> b;
cout << lgput(a,b);
return 0;
}
