Cod sursa(job #2183158)
| Utilizator | Data | 22 martie 2018 21:09:43 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.41 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
typedef unsigned long long ll;
ll n,p;
ll putere(ll x, ll y) {
if(y==1) return x;
ll aux=putere(x, y/2);
if(y&1) return ((((aux*aux)%MOD)*x)%MOD);
return (aux*aux)%MOD;
}
int main()
{
fin>>n>>p;
fout<<putere(n,p);
return 0;
}
