Cod sursa(job #1806583)
| Utilizator | Data | 15 noiembrie 2016 15:40:31 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include <iostream>
#include <cstdio>
#define modul 1999999973
using namespace std;
long long n, p;
void putere()
{
long long tmp = 1;
while(p != 1)
{
if(p % 2 == 1)
{
tmp *= (n % modul);
p--;
}
n *= (n % modul);
p /= 2;
}
printf("%lld",(n * tmp) % modul);
}
void citire()
{
scanf("%lld %lld",&n,&p);
putere();
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
citire();
return 0;
}
