Cod sursa(job #3161856)
Utilizator | Data | 28 octombrie 2023 09:40:00 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream fin("moka.in");
ofstream fout("moka.out");
int main(){
long long a, b;
fin >> a >> b;
a = a % MOD;
int p = 1;
while(b){
if(b%2==1)
p = (p*a)%MOD;
b /= 2;
a = (a*a)%MOD;
}
fout << p;
fin.close();
fout.close();
}