Cod sursa(job #3213679)
Utilizator | Data | 13 martie 2024 12:46:33 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int ExpRap(long long a, long long n)
{
int p = 1;
while (n > 1)
{
if (n % 2 == 1)
p = a * p % MOD;
n /= 2;
a = a * a % MOD;
}
return a;
}
int main()
{
long long n, P;
fin >> n >> P;
fout << ExpRap(n, P) << " ";
}