Cod sursa(job #1509111)
Utilizator | Data | 23 octombrie 2015 15:21:45 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <iostream>
using namespace std;
int main()
{
int n,k,r=1;
cin>>n>>k;
while(k!=1)
{
if(k%2==0)
{
n=n*n;
k=k/2;
}
else
{
k=k-1;
r=r*n;
}
}
n=n*r;
cout <<n<< endl;
cout << "Hello world!" << endl;
return 0;
}