Cod sursa(job #2762899)
Utilizator | Data | 9 iulie 2021 20:54:34 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD=1999999973;
int power(int b,int e)
{
if(e==0)
return 1;
if(e==1)
return b;
if(e%2==1)
return b * power(b,e-1);
return (power(b,e/2) % MOD * power(b,e/2) % MOD) %MOD;
}
int a,b;
int main()
{
fin>>a>>b;
fout<<power(a,b);
return 0;
}