Cod sursa(job #1967651)
| Utilizator | Data | 16 aprilie 2017 21:29:14 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.3 kb |
#include<fstream>
using namespace std;
ifstream f ("lgput.in");
ofstream g ("lgput.out");
long long n,p,a;
int main()
{
f>>n>>p;
a=1;
while(p>0){
if(p%2){
p--;
a=(n*a)%1999999973;
}
else p=p/2,n=(n*n)%1999999973;
}
g<<a;
}
