Cod sursa(job #2089787)
Utilizator | Data | 17 decembrie 2017 10:42:54 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
#include <iostream>
using namespace std;
int n,x;
unsigned long long pat(int x,int n)
{
if(n==0)
return 1;
if(n%2==0)
return pat(x*x%1999999973,n/2);
else
return x*pat(x*x%1999999973,(n-1)/2);
}
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin>>x>>n;
fout<<pat(x,n)%1999999973;
}