Cod sursa(job #2508713)
Utilizator | Data | 12 decembrie 2019 20:00:41 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int main()
{ int n,p,r=1,mod=1999999973;
f>>n>>p;
while(p){
if(p%2 != 0)
r = (1LL *r*n)%mod;
n= (1LL* n*n)%mod;
p = p/2;
}
g << r;
return 0;
}