Cod sursa(job #3039815)
Utilizator | Data | 28 martie 2023 21:27:11 | |
---|---|---|---|
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 f("lgput.in");
ofstream g("lgput.out");
int n, p;
int MOD = 1999999973;
int main()
{
f>>n>>p;
long long rez = 1;
while(p != 0)
{
if(p % 2 == 1)
{
rez = (1LL * rez * n) % MOD;
}
n = (1LL * n * n) % MOD;
p = p / 2;
}
g<<rez;
return 0;
}