Cod sursa(job #3030438)
Utilizator | Data | 17 martie 2023 17:50:11 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int modulo=1999999973;
long long putere(long long a,long long b)
{
if(b==0)
return 1;
long long p=putere(a,b/2);
p=(p*p)%modulo;
if(b%2==1)
return (p*a)%modulo;
else
return p;
}
long long a,b;
int main()
{
fin>>a>>b;
fout<<putere(a,b);
return 0;
}