Cod sursa(job #2943676)
Utilizator | Data | 21 noiembrie 2022 15:25:41 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int M=1999999973;
int putere(int n,int a){
int p=1;
while(n){
cifb=n%2;
if(cifb>0) p=(long long)p*a%M;
a=(long long)a*a;
}
return p;
}
int main(){
int n,p;
fin>>n>>p;
fout<<putere(n,p);
fin.close();
fout.close();
return 0;
}