Cod sursa(job #3311930)
| Utilizator | Data | 24 septembrie 2025 23:11:48 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.57 kb |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1999999973;
long long exp(int n, long long base)
{
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);
int n, p;
cin >> n >> p;
cout << exp(n, p);
return 0;
}
