Cod sursa(job #2706853)
Utilizator | Data | 15 februarie 2021 21:50:17 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
#define Mod 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long a,b;
int logPow()
{
int rez=1;
while(b)
{
if(b%2)
rez=(rez*a)%Mod;
a=(a*a)%Mod;
b/=2;
}
return rez;
}
int main()
{
f>>a>>b;
g<<logPow();
return 0;
}