Cod sursa(job #589646)
Utilizator | Data | 13 mai 2011 09:41:19 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
# include <fstream>
using namespace std;
ifstream f ("lgput.in");
ofstream g ("lgput.out");
long long a, b;
long long powr (long long a){
long long t = b, ret = 1;
for (; a > 0; a >>= 1){
if (a & 1)
ret = (ret * t) % 1999999973;
t = (t * t) % 1999999973;
}
return ret;
}
int main (){
f >> b >> a;
g << powr (a);
return 0;
}