Cod sursa(job #1999802)
Utilizator | Data | 12 iulie 2017 10:01:03 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
#define rest 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long int n,p,x=1;
void putere()
{
while(p)
{
if(p%2==1)
{
x=(x*n)%rest;
p--;
}
else
{
n*=n;
p/=2;
}
}
}
int main()
{
f>>n>>p;
putere();
g<<x;
return 0;
}