Cod sursa(job #1911947)
Utilizator | Data | 7 martie 2017 22:22:15 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
using namespace std;
int x,n;
int pow(int x,int n)
{
int y=1;
while(n>1) if(n%2) x*=x,n/=2,x%=MOD,y*=x;
else x*=x,n/=2,x%=MOD;
return x*y%MOD;
}
void read()
{
ifstream f("lgput.in");
f>>x>>n;
f.close();
}
void write()
{
ofstream g("lgput.out");
g<<pow(x,n);
g.close();
}
int main()
{
read();
write();
}