Cod sursa(job #3225177)
| Utilizator | Data | 16 aprilie 2024 23:27:55 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
#include <iostream>
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long recursiv(long long x,int n)
{
int x_pat;
x_pat = (x * x)%mod;
if(n ==0)
return 1;
else
if(n%2==0)
return recursiv(x_pat,n/2);
else
return x*recursiv(x_pat,(n-1)/2);
}
int main()
{
long long P=1;
long long baza,exp;
fin>>baza>>exp;
cout<<recursiv(baza,exp);
return 0;
}
