Cod sursa(job #1462683)
Utilizator | Data | 18 iulie 2015 18:03:36 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <fstream>
#define LL long long
#define mod 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
LL power(LL x,LL n)
{
LL rez;
if (n==0) return 1;
rez=power((x*x)%mod,n/2);
if (n%2) rez=(rez*x)%mod;
return rez;
}
int main()
{
LL x,n;
f>>x>>n;
g<<power(x,n);
return 0;
}