Cod sursa(job #3210387)

Utilizator mihaigeorgescuGeorgescu Mihai mihaigeorgescu Data 6 martie 2024 09:57:38
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.32 kb
#include <fstream>

using namespace std;
ifstream fcin("lgput.in");
ofstream fout("lgput.out");
int x,y,p,c,n;
int main()
{
    fcin>>x>>y;
    p=1;
    while(y!=0)
    {
        c=y%2;
        if(c==1)
        {
            p=p*x;
        }
      y=y/2;
      x=x*x;
    }
    fout<<p;
    return 0;
}