Cod sursa(job #3123817)
Utilizator | Data | 25 aprilie 2023 16:43:53 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long calcul(int a, int b)
{
if(b==0)
return 1;
else
{
long long x=calcul(a, b/2);
if(b%2==0)
return x*x%MOD;
else
return x*x%MOD*a%MOD;
}
}
int a, b;
int main()
{
fin>>a>>b;
fout<<calcul(a, b);
return 0;
}