Cod sursa(job #3261381)
Utilizator | Data | 5 decembrie 2024 17:40:58 | |
---|---|---|---|
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;
const int MOD = 1999999973;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
int n, a, p = 1;
fin >> a >> n;
while(n != 0)
{
int cifb = n % 2;
if(cifb != 0)
{
p = ((long long)p * a) % MOD;
}
a = ((long long)a * a) % MOD;
n /= 2;
}
fout << p;
return 0;
}