Cod sursa(job #2931835)
| Utilizator | Data | 31 octombrie 2022 23:36:28 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include <iostream>
#include <fstream>
#define Nr 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long exp(long long n,long long p){
long long ans = 1;
while(p>0){
if(p%2 == 1){
ans = (ans * n) % Nr;
p--;
}
n = (n*n)%Nr;
p /= 2;
}
return ans;
}
int main()
{
long long N,P;
fin>>N>>P;
fout<<exp(N,P);
return 0;
}
