Cod sursa(job #2335881)

Utilizator ewaldBerla Ewald ewald Data 4 februarie 2019 16:45:53
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.35 kb
#include <fstream>
#include <iostream>
using namespace std;

ifstream f("lgput.in");
ofstream g("lgput.out");

int power(int x,int y){
  if(y==0)
    return 1;
  if(y==1)
    return x;
    if(y%2==0)
        return power(x*x,y/2);
        return x*power(x*x,y/2);
}

int main(){
    int x;
    int y;
    cin>>x>>y;
    cout<<power(x,y);
}