Cod sursa(job #1047263)
Utilizator | Data | 4 decembrie 2013 09:40:27 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include<fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,p,rez,mod=1999999973;
int main()
{
f>>n>>p;
rez=1;
while(p>0)
{
if(p%2) rez=(rez*n)%mod;
p=p/2;
n=(n*n)%mod;
}
g<<rez<<'\n';
g.close();
return 0;
}