Cod sursa(job #2278640)
Utilizator | Data | 8 noiembrie 2018 12:59:30 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <iostream>
#include <fstream>
#define LL long long
using namespace std;
LL put(LL a, LL b ,LL m)
{
LL sol=1;
LL put=b;
for(LL i=1;i<=a;i=i << 1)
{
if(i & a )sol=sol*put%m;
put=put*put%m;
}
return sol;
}
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
LL a,b;
f>>b>>a;
g<<put(a,b,1999999973);
f.close();
g.close();
}