Cod sursa(job #960347)
Utilizator | Data | 10 iunie 2013 11:45:13 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#define ll long long
#include<fstream>
using namespace std;
unsigned int n,p,a;
ll prod=1;
const int M=1999999973;
ifstream f("lgput.in"); ofstream g("lgput.out");
int main ()
{ f>>n>>p;
a=n;
for(int i=0;(1<<i)<=p;++i)
{if(((1<<i)&p)>0) prod=prod*n%M;
a=a*a%M;}
g<<prod<<'\n';
g.close (); return 0;
}