Cod sursa(job #3289073)
| Utilizator | Data | 25 martie 2025 14:49:48 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <bits/stdc++.h>
#define int long long
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
int lgput(int n, int a)
{
if(a==0)
{
return 1;
}
else if(a%2 == 0)
{
int val = lgput(n, a/2);
return (val*val) % MOD;
}
else
{
return (n * lgput(n, a - 1)) % MOD;
}
}
signed main()
{
int n, p;
fin >> n >> p;
fout << lgput(n, p);
return 0;
}
