Cod sursa(job #942253)
Utilizator | Data | 21 aprilie 2013 18:28:15 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include<fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,p;
void read_number(long long& x)
{
f>>x;
}
void power_log()
{
int sol=1;
while(p)
{
if(p%2==1)
sol=(sol*n)%1999999973;
n=(n*n)%1999999973;p=p/2;
}
g<<sol<<"\n";
}
int main()
{
read_number(n);
read_number(p);
power_log();
}