Cod sursa(job #3164713)
Utilizator | Data | 4 noiembrie 2023 10:01:19 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
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");
#define MOD 1999999973
long long p,prod,n;
int main()
{
prod=1;
fin>>n>>p;
while(p>0){
if(p%2==1)
prod=(prod*(n%MOD))%MOD;
n=((n%MOD)*(n%MOD))%MOD;
p=p/2;
}
fout<<prod;
return 0;
}