Cod sursa(job #1384656)
Utilizator | Data | 11 martie 2015 12:00:17 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int a,b,x,i,sol=1;
int main(){
fin>>a>>b;
x=1999999973;
while(b>0){
if(b%2==1)
sol=(1ll*sol*a)%x;
a=(1ll*a*a)%x;b=b/2;
}
/*
for(i=1;i<=b;i++)
sol=(sol*a)%x;
*/
fout<<sol;fout.close();
return 0;
}