Cod sursa(job #2983068)
Utilizator | Data | 21 februarie 2023 15:29:41 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
ll a,b,mod=1999999973;
int fastexp(ll a,ll b)
{
ll r=1;
while(b)
{
if(b&1)
{
r=(r*a)%mod;
b--;
}
b=b/2;
a=(a*a)%mod;
}
return r;
}
int main()
{
f>>a>>b;
g<<fastexp(a,b);
return 0;
}