Mai intai trebuie sa te autentifici.
Cod sursa(job #2189984)
Utilizator | Data | 29 martie 2018 15:54:26 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.47 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
#define ll long long
ll N, P ,M;
ll expo(ll a,ll b)
{
ll aux = 1;
while( b != 1 )
{
if( b % 2 == 1 )
aux = aux * a % M;
a = a * a % M;
b >>= 1;
}
return aux * a % M;
}
int main()
{
M = 1999999973;
f >> N >> P;
g << expo(N,P);
f.close();
g.close();
return 0;
}