Cod sursa(job #2628244)
Utilizator | Data | 15 iunie 2020 09:17:09 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
using namespace std;
const int MOD = 1999999973;
ifstream f("lgput.in");
ofstream g("lgput.out");
int powlg(int a, int p)
{
long long x = a;
int val = 1;
while(p > 0)
{
if(p & 1)
val = val * x % MOD;
x = x * x % MOD;
p >>= 1;
}
return val;
}
int main()
{
int a, b;
f >> a >> b;
g << powlg(a, b);
return 0;
}