Cod sursa(job #3213689)
Utilizator | Data | 13 martie 2024 12:49:25 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 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)
{
long long p = 1;
while (n > 0)
{
if (n % 2 == 1)
p = a * p % MOD;
n /= 2;
a = a * a % MOD;
}
return p;
}
int main()
{
long long n, P;
fin >> n >> P;
fout << ExpRap(n, P) << "\n";
}