Cod sursa(job #3169769)
Utilizator | Data | 15 noiembrie 2023 21:54:52 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int m = 1999999973;
long long a, b;
long long p = 1;
int main()
{
fin >> a >> b;
while(b>0)
{
if(b&1==1)
{
p = 1LL*(p%m*a%m)%m;
}
a = 1LL*(a%m*a%m)%m;
b/=2;
}
fout << 1LL*p;
return 0;
}