Cod sursa(job #1408277)
Utilizator | Data | 29 martie 2015 22:38:05 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <cstdio>
using namespace std;
int x, y, mod=1999999973;
int putere (int x, int y)
{
if(y==1) return x;
else if (y%2==0) return putere(x*x, y/2)%mod;
else return x*(putere(x*x, y/2))%mod;
}
int main()
{
freopen ("lgput.in", "r", stdin);
freopen ("lgput.out", "w", stdout);
scanf ("%d%d", &x, &y);
printf ("%d", putere(x,y)%mod);
}