Cod sursa(job #3001474)
Utilizator | Roberta Nechita robertanechita1 | Data | 13 martie 2023 18:21:59 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int mod = 1999999973;
int n, p;
long long ans = 1;
long long LogP(int a, int p){
while(p){
if( p % 2 == 1 )
ans = 1LL * ans * a % mod;
p /= 2;
a = 1LL * a * a % mod;
}
return ans;
}
int main()
{
fin >> n >> p;
fout << LogP(n, p) << "\n";
return 0;
}