Cod sursa(job #2576349)
Utilizator | Data | 6 martie 2020 18:42:03 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
using namespace std;
#define mod 1999999973
ifstream f("lgput.in");
ofstream g("lgput.out");
int N,P;
int ExpRap(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()
{
f>>N>>P;
g<<ExpRap(N,P);
return 0;
}