Cod sursa(job #1899851)
Utilizator | Data | 2 martie 2017 22:53:19 | |
---|---|---|---|
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");
int main()
{
long long a,b;
f>>a>>b;
long long put=1;
while(b>0){
if(b%2==1){
b--;
put=(a*put)%1999999973;
}
else b=b/2,a=(a*a)%1999999973;
}
g<<put;
}