Cod sursa(job #2841175)
| Utilizator | Data | 29 ianuarie 2022 12:56:51 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| 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 n, p;
int power(int n, int p)
{
int x = 1;
while(p>0)
{
if(p%2==1)
{
x = 1LL * x * n % MOD;
}
p /= 2;
n = 1LL * n * n % MOD;
}
return x;
}
int main()
{
fin >> n >> p;
fout << power(n, p);
return 0;
}