Cod sursa(job #3311931)
| Utilizator | Data | 24 septembrie 2025 23:15:24 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.58 kb |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1999999973;
long long exp(long long base, int n)
{
long long ans = 1;
while(n)
{
if(n % 2 == 1)
{
ans *= base;
ans %= MOD;
}
base *= base;
base %= MOD;
n /= 2;
}
return ans;
}
int main()
{
ios_base :: sync_with_stdio(0);
cin.tie(0);
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
long long n, p;
cin >> n >> p;
cout << exp(n, p);
return 0;
}
