Cod sursa(job #2123713)
Utilizator | Data | 6 februarie 2018 15:57:55 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int putere(int n,int x)
{
if(x==0)return 1;
if(x==1)return n;
int a=putere(n,x/2);
if(x%2==0)return (a*a)%MOD;
else return (a*a)%MOD*n%MOD;
}
int x,y;
int main()
{
f>>x>>y;
g<<putere(x,y);
return 0;
}