Cod sursa(job #2946105)
Utilizator | Iacobai Cosmin Andrei cosmin1805 | Data | 24 noiembrie 2022 16:02:24 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const long long MOD = 1999999973;
int main()
{
int a, n, p = 1;
fin >> a >> n;
while (n != 0)
{
int b = n % 2;
if (b != 0)
{
p = (long long)p * a % MOD;
}
a = (long long)a * a % MOD;
n /= 2;
}
fout << p;
return 0;
}