Cod sursa(job #2573676)
Utilizator | Data | 5 martie 2020 18:40:12 | |
---|---|---|---|
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
#define ll long long
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
ll lgput(ll n,ll p){
ll ans=1;
while(p){
if(p%2) ans=(ans*n)%MOD;
n=(n*n)%MOD;
p/=2;
}
return ans;
}
int main()
{
ll n,p;
f>>n>>p;
g<<lgput(n,p);
return 0;
}