Cod sursa(job #2763376)
Utilizator | Data | 13 iulie 2021 14:32:53 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <iostream>
#include <fstream>
#define Mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
int a, b;
fin >> a >> b;
long long res = 1;
while(b)
{
if(b % 2 == 1)
{
res = (res * a) % Mod;
}
b /= 2;
a = (a * a) % Mod;
}
fout << res;
return 0;
}