Cod sursa(job #2639491)
Utilizator | Data | 2 august 2020 13:40:40 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
long long c,r=1,a,b,x;
int main()
{
c=1999999973;
in>>a>>b;
x=a;
while(b)
{
if(b%2==1)
{
r=(r*x)%c;
}
x=(x*x)%c;
b=b/2;
}
out<<r;
return 0;
}