Cod sursa(job #2718334)

Utilizator valentinchipuc123Valentin Chipuc valentinchipuc123 Data 8 martie 2021 17:57:56
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda no-time-to-rest Marime 0.39 kb
#include <bits/stdc++.h>

using namespace std;

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

long long n,p;
const long long mod=1999999973;

long long putere(long long a,long long b)
{

 long long sol=1,put=a;

 while( b>0 )
 {
  if( b%2==1 ) sol= (1LL*sol*put)%mod;

  put=(1LL*put*put)%mod;
  b/=2;
 }

 return sol;
}

int main()
{
 f>>n>>p;

 g<<putere(n,p);
}