Cod sursa(job #3124475)
Utilizator | Data | 28 aprilie 2023 22:52:52 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
using namespace std;
long long a, b, c, i;
ifstream fin ("lgput.in");
ofstream fout("lgput.out");
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*a%1999999973;
}
}
int main () {
fin>>a>>b;
fout<<calcul(a, b);
return 0;
}