Cod sursa(job #979105)
Utilizator | Data | 31 iulie 2013 17:40:06 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.29 kb |
#include <fstream>
#define DIV 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int main()
{
unsigned long long n,p,a=1;
f>>n>>p;
for(;p>1;p>>=1)
{
if(p%2==1)
a=a*n%DIV;
n=n*n%DIV;
}
g<<n*a%DIV;
}