Cod sursa(job #2873330)
Utilizator | Data | 19 martie 2022 09:37:42 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long putere(long long a, long long b)
{
long long p=1%MOD;
do
{
if(b%2==1)
p*=a%MOD;
b/=2;
a%=MOD;
a*=a%MOD;
}while(b!=0);
return p;
}
int main()
{
long long a,b;
fin>>a>>b;
fout<<putere(a,b);
return 0;
}