Cod sursa(job #1926467)
| Utilizator | Data | 14 martie 2017 13:11:38 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
#define Mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int Pow(int b,int p)
{
if(p==0)
return 1;
int x = Pow(b,p/2);
if(p%2==0)
return 1LL*x*x % Mod;
return 1LL*x*x%Mod*b%Mod;
}
int main()
{
int n,p;
fin>>n>>p;
fout<<Pow(n,p);
return 0;
}
