Cod sursa(job #2763374)
| Utilizator | Data | 13 iulie 2021 14:23:42 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.57 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)
{
long long res = 1;
if(exp == 0)
fout << 1;
if(exp == 1)
fout << baza;
while(exp)
{
if(exp % 2 == 1)
res = (res * baza) % Mod;
baza = baza * baza;
exp = exp / 2;
}
fout << (res * baza) % Mod;
}
int main()
{
int baza, exp;
fin >> baza >> exp;
LOG(baza, exp);
return 0;
}
