Cod sursa(job #3342015)
| Utilizator | Data | 22 februarie 2026 14:23:22 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
int main()
{
int n, p, rez = 1;
cin>>n>>p;
while (p != 0) {
if (p % 2 == 1) {
rez = (rez*n)%MOD;
}
n = (n*n)%MOD;
p /= 2;
}
cout<<rez;
return 0;
}
