Cod sursa(job #2706276)
Utilizator | Data | 14 februarie 2021 14:49:43 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
int main() {
int n,p;
long long Pow = 1,a;
fin>>n>>p;
a = n;
while(p != 0){
if(p%2){
Pow = (Pow*a)%MOD;
}
a=(a*a)%MOD;
p/=2;
}
fout<<Pow<<'\n';
return 0;
}