Cod sursa(job #3030679)
Utilizator | Data | 17 martie 2023 20:06:22 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <bits/stdc++.h>
#define mod 1999999973
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
long long N, P;
int main()
{
in >> N >> P;
long long exp, rasp = 1;
while(P > 0)
{
if(P % 2 == 1) rasp = (rasp * N) % mod;
N = (N * N) % mod;
P/=2;
}
out << rasp << "\n";
return 0;
}