Cod sursa(job #232159)
| Utilizator | Data | 14 decembrie 2008 20:51:13 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.33 kb |
#include<fstream>
using namespace std;
ifstream f ("lgput.in");
ofstream g ("lgput.out");
long long n,p,rez=1,m=1999999973;
int main()
{
f>>n>>p;
while(p>0){
if (p%2==1) rez=(rez*n)%m;
n=(n*n)%m;
p=p/2;
}
g<<rez;
f.close();
g.close();
return 0;
}
