Cod sursa(job #1959245)
Utilizator | Data | 9 aprilie 2017 11:35:02 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <fstream>
#include<iostream>
#include <cmath>
#define md 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n,p, rs;
int main(){
fin>>n>>p;
rs=1;
while(p!=1){
if(p%2==1) rs=rs*n%md;
n=n*n%md; p/=2;
}
fout<<n*rs%md;
return 0;
}