Cod sursa(job #3187158)
Utilizator | Data | 27 decembrie 2023 20:00:10 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.28 kb |
#include<bits/stdc++.h>
using namespace std;
int main(){
const int mod = 1999999973;
long long int n, p;
int j = 1;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin>>n>>p;
while(p){ // 4
if(p%2==1){
j=(j*n)%mod;
}
n=(n*n)%mod; // 16
p/=2; // 1
}
fout<<j;
}