Cod sursa(job #1509844)
Utilizator | Data | 24 octombrie 2015 12:43:15 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int main()
{ long long n,p,prod=1;
f >>n>>p;
while (p!=1)
{if (p%2==0)
{
n=n*n;
p=p/2;
}
else {prod=prod*n;p--;}
}
g <<(n*prod)%1999999973;
return 0;
}