Cod sursa(job #2998356)
| Utilizator | Data | 9 martie 2023 12:35:26 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include<fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int a , b;
long long alab (int a , int b)
{
if (b == 0)
return 1;
int p = alab (a , b / 2);
if (b % 2 == 1)
return (1LL * p % 1999999973 * p % 1999999973 * a % 1999999973) % 1999999973;
else
return (1LL * p % 1999999973 * p % 1999999973) % 1999999973;
}
int main()
{
f >> a >> b;
g << alab (a , b);
return 0;
}
