Cod sursa(job #2758696)
Utilizator | Data | 12 iunie 2021 09:10:34 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <iostream>
#include <fstream>
#define MOD 1999999973
using namespace std;
int a,n,p = 1;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
fin >> a >> n;
while(n != 0){
if(n%2 != 0){
p = 1ll*p*a%MOD;
}
a = 1ll*a*a%MOD;
n /= 2;
}
fout << p << "\n";
return 0;
}