Cod sursa(job #918867)
Utilizator | Data | 19 martie 2013 10:30:57 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include<iostream>
#include <fstream>
using namespace std;
#define ULL unsigned long long
const int M=1999999973;
ULL n,p,s,i;
int main()
{
ifstream f("lgput.in");
f >> n >> p;
f.close();
s=1;
for(i=0; (1<<i)<=p; ++i)
{
if((1<<i)&p)
s=s*n%M;
n=n*n%M;
}
ofstream g("lgput.out");
cout << g;
g.close();
return 0;
}