Cod sursa(job #1604710)
Utilizator | Data | 18 februarie 2016 15:13:57 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.23 kb |
#include<fstream>
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*=n,--p;
else n*=n,p/=2;
out<<r;
return 0;
}