Cod sursa(job #3322567)
| Utilizator | Data | 14 noiembrie 2025 19:25:13 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
typedef long long ll;
const ll MOD=1999999973;
ll lgpow(ll a,ll n) {
ll res=1;
while(n) {
if(n%2) {
res=(res*a)%MOD;
}
a=(a*a)%MOD;
n/=2;
}
return res;
}
int main() {
ll a,n;
fin>>a>>n;
fout<<lgpow(a,n);
return 0;
}
