Cod sursa(job #2467785)
Utilizator | Data | 5 octombrie 2019 08:15:58 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
#define nat long long
using namespace std;
ifstream fin("lqput.in");
ofstream fout("lgput.out");
nat lgput(nat a, nat n)
{
nat p = 1;
while(n)
{
if(n % 2 == 1) p = 1LL * p * a % MOD;
n /= 2;
a = 1LL * a * a % MOD;
}
return p;
}
int main()
{
nat a, b;
fin >> a >> b;
fout << lgput(a,b);
return 0;
}