Cod sursa(job #2812298)
Utilizator | Data | 4 decembrie 2021 12:32:25 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <iostream>
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int fast_exp(int a, int b)
{
int ans = 1;
while(b)
{
if(b & 1)
ans = (ans * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return ans;
}
int main()
{
int n, p;
fin>>n>>p;
fout<<fast_exp(n, p);
return 0;
}