Cod sursa(job #2412413)
Utilizator | Data | 22 aprilie 2019 11:21:48 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <fstream>
using namespace std;
ifstream in ("lgput.in");
ofstream out ("lgput.out");
long long rise(long long a,long long b)
{
long long x;
if(b==0)return 1;
else{
x=rise(a,b/2);
if(b%2==1)return x*a*x;
else{return x*x;}
}
}
int main()
{long long a,b;
in>>a>>b;
out<<rise(a,b);
return 0;
}