Cod sursa(job #763485)
| Utilizator | Data | 2 iulie 2012 13:50:58 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
#include <cstdio>
#include <algorithm>
using namespace std;
#define MOD 1999999973
typedef long long ll;
ll n;
ll pow(ll p){
if(p == 1)return n; else
{
ll z = pow(p/2);
if(p%2)return z*z%MOD*n%MOD; else
return z*z%MOD;
}
}
int main(){
long long p;
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld %lld",&n,&p);
printf("%lld\n",pow(p));
return 0;
}
