Cod sursa(job #3260143)
Utilizator | Data | 30 noiembrie 2024 12:23:20 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <fstream>
using namespace std;
ifstream fin("euclid2.in");
ofstream fout("euclid2.out");
int x,y;
int powlog(int a,int b){
int p=1;
while(b!=0){
if(b%2==1)
p=p*a;
a=a*a;
b=b/2;
}
return p;
}
int main()
{
fin>>x>>y;
fout<<powlog(x,y);
return 0;
}