Cod sursa(job #2669238)
Utilizator | Data | 6 noiembrie 2020 15:53:00 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgputW.out");
long long a,b;
long long pow(long long a, long long b)
{
long long rez = 1;
while(b)
{
if(b & 1)
rez = (rez * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return rez;
}
int main()
{
f >> a >> b;
g << pow(a,b);
return 0;
}