Cod sursa(job #2998380)
| Utilizator | Data | 9 martie 2023 12:43:29 | |
|---|---|---|---|
| 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 mod 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int n , p;
int ridicare_logaritmica(int n , int p)
{
int rez = 1;
while(p)
{
if(p % 2 == 1)
rez = (1ll * rez * n) % mod;
n = (1ll * n * n) % mod;
p = p / 2;
}
return rez;
}
int main()
{
f >> n >> p;
g << ridicare_logaritmica(n , p);
return 0;
}
