Cod sursa(job #2365617)
| Utilizator | Data | 4 martie 2019 15:13:46 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.54 kb |
#include <bits/stdc++.h>
#define modulo 1999999973
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
int PutLog(int a, int n)
{
long long rez = 1;
while (n != 0)
{
if (n % 2 == 1)
rez = (1LL * rez * a) % modulo;
a = (1LL * a * a) % modulo;
n /= 2;
}
return rez;
}
int main()
{
int baza, putere;
fin >> baza >> putere;
int x = PutLog(baza, putere);
fout << x << "\n";
fin.close();
fout.close();
return 0;
}
