Cod sursa(job #1047272)
Utilizator | Data | 4 decembrie 2013 09:45:20 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
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;
}