Cod sursa(job #2311103)
| Utilizator | Data | 2 ianuarie 2019 17:09:12 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const modulo=1999999973;
void power(long long n,long long p,long long &solution){
while(p){
if(p%2==1) solution=solution*n%modulo;
n=n*n*modulo;
p=p/2;
}
}
int main(){
long long n,p,solution;
fin>>n>>p;
solution=1;
power(n,p,solution);
fout<<solution;
return 0;
}
