Cod sursa(job #3308593)
| Utilizator | Data | 26 august 2025 14:23:09 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD=1999999973;
int put(int a, int b){
if(b==0){
return 1;
}
if(b%2==1){
return (put(a,b/2)*put(a,b/2)*a)%MOD;
}
else{
return (put(a,b/2)*put(a,b/2))%MOD;
}
}
int main(){
int n, p;
fin>>n>>p;
fout<<put(n,p);
}