Cod sursa(job #2456276)
Utilizator | Data | 14 septembrie 2019 09:23:40 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <bits/stdc++.h>
#define ll long long
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll P1(ll a, ll n)
{
ll p=1;
while (n>0)
{
if (n%2==1)
p=p*a%MOD;
n/=2;
a=a*a%MOD;
}
return p;
}
int main()
{
ll a,b;
fin>> a >> b;
fout << P1(a,b);
return 0;
}