Cod sursa(job #2569526)
Utilizator | Data | 4 martie 2020 12:27:45 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long a,b,M,R;
int main()
{
int i,j;
M=1999999973;
f >> a >> b;
R=1;
a=a%M;
while (b>0)
{
if (b%2==1)
{
R=(R*a)%M;
}
b=b/2;
a=(a*a)%M;
}
g << R;
return 0;
}