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