Cod sursa(job #3187151)
Utilizator | Data | 27 decembrie 2023 19:44:43 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.26 kb |
#include<bits/stdc++.h>
using namespace std;
void main(){
int mod = 1999999973;
int n, p, 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;
}
}