Cod sursa(job #3286280)
| Utilizator | Data | 13 martie 2025 22:06:53 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <bits/stdc++.h>
using namespace std;
int64_t const MOD = 1999999973;
int const inf = 2e9;
int64_t n , p;
int64_t expo(int64_t a , int64_t b){
int64_t r = 1;
while(b){
if(b & 1)a = a * a * r % MOD;
b >>= 1;
r *= a;
}
return a;
}
int main()
{
freopen("lgput.in" , "r" , stdin);
freopen("lgput.out" , "w" , stdout);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> n >> p;
cout << expo(n , p);
}
