Cod sursa(job #3304838)
| Utilizator | Data | 27 iulie 2025 20:27:14 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <iostream>
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream fin ("Igput.in");
ofstream fout ("Igput.out");
int exponentiere(int n, long long p);
int main()
{
int n;
long long p;
fin>>n>>p;
fout<<exponentiere(n,p);
}
int exponentiere(int n, long long p)
{
if (p==0)
{
return 1;
}
if (p%2==0)
{
return (exponentiere(n,p/2)*exponentiere(n,p/2))%MOD;
}
return (((exponentiere(n,p/2)*exponentiere(n,p/2))%MOD)*n)%MOD;
}