Cod sursa(job #493093)
Utilizator | Data | 17 octombrie 2010 00:35:46 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.26 kb |
#include <fstream>
using namespace std;
int m=1999999973;
int main()
{
long long int n,p,rez=1;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin>>n>>p;
while(p>0)
{
if(p%2==1) rez=rez*n%m;
n=n*n%m;
p/=2;
}
fout<<rez%m;
}