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