Cod sursa(job #3207937)
Utilizator | Data | 27 februarie 2024 09:46:52 | |
---|---|---|---|
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>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
typedef long long ll;
ll a,p,mod;
ll pw(ll a,ll b,ll mod)
{
ll p=1;
while(b)
{
if(b&1)
p=(p*a)%mod;
a=(a*a)%mod;
b/=2;
}
return p;
}
int main()
{
fin>>a>>p;
mod=1999999973;
fout<<pw(a,p,mod);
return 0;
}