Cod sursa(job #1152061)
| Utilizator | Data | 24 martie 2014 15:30:56 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int n,p;
long long exp(int x,int y)
{
if(!y)return 1;
else
if(y%2) return(x%1999999973)*(exp(x, y-1)%1999999973)%1999999973;
else
{
long long p2;
p2=exp(x,y/2)%1999999973;
return (p2%1999999973)*(p2%1999999973)%1999999973;
}
}
int main()
{
fin>>n>>p;
fout<<exp(n,p)<<'\n';
return 0;
}
