Cod sursa(job #2656248)
Utilizator | Data | 7 octombrie 2020 11:02:34 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <iostream>
#define MOD 1999999973;
using namespace std;
int b, a, rez = 1;
int main()
{
ifstream fin("lgput.in");
fin >> a >> b;
fin.close();
while(b)
{
if(b % 2 == 1)
rez = 1LL * a % MOD;
a = 1LL * a * a% MOD;
b /= 2;
}
ofstream fout("lgput.out");
fout << rez;
fout.close();
return 0;
}