Cod sursa(job #3269537)
| Utilizator | Data | 19 ianuarie 2025 15:11:51 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long N,P;
const int MOD = 1999999973;
long long lgpow(long long base,long long exponent){
long long rez = 1;
while(exponent > 0){
if((exponent & 1)){
rez = rez * base;
rez %= MOD;
}
base = (base * base) % MOD;
exponent = exponent >> 1;
}
return rez;
}
int main()
{
f>>N>>P;
g<<lgpow(N,P);
}
