Cod sursa(job #1047268)

Utilizator infontTanase Emanuel infont Data 4 decembrie 2013 09:42:26
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.26 kb
#include<fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,p,rez,mod=1999999973;
int main(){
f>>n>>p;
rez=1;
while(p){
if(p%2)
rez=(rez*n)*mod;
p=p/2;
n=(n=+n)%mod;
}
g<<rez<<'\n';
g.close();
return 0;
}