Cod sursa(job #3124457)
| Utilizator | Data | 28 aprilie 2023 19:52:03 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream fin ("lgput.in");
ofstream fout("lgput.out");
long long a,b;
long long putereRec(long long a,long long b)
{
if(b==0)
return 1;
else
if(b%2==0)
return putereRec(a,b/2)*putereRec(a,b/2)%mod;
else
return putereRec(a,b/2)*putereRec(a,b/2)%mod*a%mod;
}
int main()
{
fin>>a>>b;
fout<<putereRec(a,b);
return 0;
}
