Cod sursa(job #3244520)

Utilizator stefangr2008Grecu Stefan stefangr2008 Data 25 septembrie 2024 09:39:30
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.44 kb
#include <iostream>
#include <fstream>
using namespace std;
const int MOD = 1999999973;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long put3(long long x, long long n)
{
    long long val = 1, a = x % MOD;
    while(n > 0)
    {
        if(n & 1)
            val = val * a % MOD ;
        a =a * a % MOD;
        n >>= 1;
    }
    return val;
}
int main()
{
   long long n, p;
   f >> n >> p;
   g << put3(n, p);
}