Cod sursa(job #2594369)
Utilizator | Data | 5 aprilie 2020 20:14:39 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout("lgput.out");
const int mod=1999999973;
int log(int x,int p){
int r=1;
while(p){
if( p & 1 == 1){
r = (1LL*r*x) % mod;}
x=(1LL*x*x)%mod;
p/=2;}
return r;
}
int main(){
int n,p;
fin>>n>>p;
fout<<log(n,p);
}