Cod sursa(job #2375640)
Utilizator | Data | 8 martie 2019 11:10:48 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <bits/stdc++.h>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int N, P, aux;
int logput(int N, int P)
{
int r=1;
while (P)
{
if (P%2 == 1)
r = (1LL*r*N)%mod;
N = (1LL*N*N)%mod;
P=P/2;
}
return r;
}
int main(void)
{
fin >> N >> P;
fout << logput(N, P);
}