Cod sursa(job #2865376)
| Utilizator | Data | 8 martie 2022 19:37:33 | |
|---|---|---|---|
| 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>
#define mod 1999999973
#define ll long long
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll putere(ll x, ll n){
if(n==0){
return 1;
}else if(n%2==0){
ll p = putere(x*x, n/2) % mod;
return p * p % mod;
}else {
ll p = putere(x*x, (n-1)/2) % mod;
return x * p * p % mod;
}
}
int main(){
ll n, p, put=1;
fin>>n>>p;
fout<<putere(n, p);
return 0;
}
