Cod sursa(job #2884471)
| Utilizator | Data | 3 aprilie 2022 19:01:07 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
const int mod = 1999999973;
ll a , b;
ll solve (ll a , ll b){
ll ans = 1;
while (b > 0){
if (b & 1){
ans = (ans % mod) * (a % mod) % mod;
}
a = (a % mod) * (a % mod) % mod;
b = b / 2;
}
return ans;
}
int main(){
ios_base::sync_with_stdio(false);
fin >> a >> b;
fout << solve(a , b);
}
