Cod sursa(job #1604713)
Utilizator | Data | 18 februarie 2016 15:15:51 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.27 kb |
#include<fstream>
#define ss 1999999973
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
long long n,p,r=1;
int main(){
in>>n>>p;
while(p)
if(p%2) r=(r*n)%ss,--p;
else n=(n*n)%ss,p/=2;
out<<r;
return 0;
}