Cod sursa(job #3345162)
| Utilizator | Data | 8 martie 2026 10:33:46 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.68 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
long long a, b, c;
long long mod = 1999999973;
long long factorial(long long b, long long a)
{
long long aux, rez;
if(a == 0)
return 1;
else if(a % 2 == 0)
{
aux = factorial(b, a / 2);
rez = aux * aux;
rez = rez % mod;
return rez;
}
else if(a % 2 == 1)
{
aux = factorial(b, a - 1) * b;
aux = aux % mod;
return aux;
}
}
int main()
{
fin >> a >> b;
fout << factorial(a,b);
return 0;
}
