Cod sursa(job #2108722)
Utilizator | Data | 18 ianuarie 2018 19:04:29 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int r, x, y;
int exponent ( int x, int y )
{
r = 1;
while ( y > 0 )
{
if ( y % 2 == 1)
r = (1ll *r * x) % 1999999973;
x = (1ll * x * x) % 1999999973;
y = y / 2;
}
return r;
}
int main()
{
f >> x >> y;
g << exponent(x,y);
return 0;
}