Cod sursa(job #1211058)
| Utilizator | Data | 21 iulie 2014 22:37:07 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
#include <iostream>
#include <stdio.h>
using namespace std;
typedef long long ll;
ll n,p;
const ll mod = 1999999973;
ll exp(ll base,ll exponent){
ll res = 1;
while(exponent){
if(exponent & 1)
res = (res * base) % mod;
base = (base * base) % mod;
exponent >>= 1;
}
return res;
}
int main(){
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&n,&p);
printf("%lld\n",exp(n,p));
return 0;
}