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