Cod sursa(job #2400283)
Utilizator | Data | 8 aprilie 2019 16:29:12 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long pt(int a, int b)
{
int r=1;
while(b)
{
if(b%2==1)
{
r=(1LL*r*a);
}
a=(1LL*a*a);
b=b/2;
}
return r;
}
int main()
{
long long a,b;
fin>>a>>b;
fout<<pt(a,b);
return 0;
}