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