Cod sursa(job #2163235)
Utilizator | Data | 12 martie 2018 17:23:03 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include<fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long a,b,p;
int main()
{
f>>a>>b;
p=1;
while(b){
if(b%2){
b--;
p=(p*a)%1999999973;
}
else {
a=(a*a)%1999999973;
b/=2;
}
}
g<<p;
}