Cod sursa(job #3218289)
Utilizator | Data | 26 martie 2024 18:53:21 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
#define mod 1999999973
using namespace std;
long long n,p;
long long po(long long x,long long exp)
{
if (exp==1)
return x;
if (exp%2==1)
return x*po(x,exp-1)%mod;
else
{
long long a=po(x,exp/2);
return a*a%mod;
}
}
int main()
{
ifstream f ("lgput.in");
ofstream g ("lgput.out");
f>>n>>p;
n%=mod;
g<<po(n,p);
}