Cod sursa(job #1387598)
Utilizator | Data | 14 martie 2015 14:57:14 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include<fstream>
using namespace std;
int n,cif,x;
long long a,p;
int main ()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin>>n>>p;
a=2;
x=n;
while(x!=0)
{
cif=x%2;
if(cif==1)
{
p=(p*a)%1999999973;
}
a=(a*a)%1999999973;
x=x/2;
}
fout<<p;
fin.close();
fout.close();
return 0;
}