Cod sursa(job #2911258)
Utilizator | Data | 28 iunie 2022 10:15:24 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <bits/stdc++.h>
using namespace std;
const int m = 1999999973;
long long a,b,i,sl;
string s;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
fin >> a >> b ;
sl=1;
for (i=0;(1<<i)<=b;i++)
{
if (((1<<i)&b)>0)
{
sl=(sl*a)%m;
}
a=(a*a)%m;
}
fout << sl <<"\n";
return 0;
}