import java.util.* ;
class Power2 {
public static void main
( String [ ] args
) { Scanner in
= new Scanner
( System .
in ) ; int valor = 0 ;
int resto;
int [ ] myArray= new int [ 31 ] ;
int ndivisoes = 0 ;
System .
out .
println ( "Valor [1..2^31] ?" ) ; valor = in.nextInt ( ) ;
while ( valor > 0 ) {
resto = valor % 2 ;
valor /= 2 ;
System .
out .
println ( "resto = " + resto
+ " / valor = " + valor
) ; myArray[ ndivisoes++ ] = resto;
}
for ( int j = ndivisoes; j >= 0 ; j-- ) {
if ( myArray[ j] == 1 ) {
System .
out .
print ( soma
+ "2^" + j
) ; soma = " + " ;
}
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwoKY2xhc3MgUG93ZXIyIHsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpewoJCVNjYW5uZXIgaW4gPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwoJCWludCB2YWxvciA9IDA7CgkJaW50IHJlc3RvOwoJCWludFtdIG15QXJyYXk9bmV3IGludFszMV07CgkJaW50IG5kaXZpc29lcyA9IDA7CgoJCVN5c3RlbS5vdXQucHJpbnRsbiggIlZhbG9yIFsxLi4yXjMxXSA/Iik7CgkJdmFsb3IgPSBpbi5uZXh0SW50KCk7CgkJU3lzdGVtLm91dC5wcmludGxuKCB2YWxvciApOwoKCQl3aGlsZSggdmFsb3IgPiAwICl7ICAgIAoJCQlyZXN0byA9IHZhbG9yICUgMjsKCQkJdmFsb3IgLz0gMjsKCQkJU3lzdGVtLm91dC5wcmludGxuKCAicmVzdG8gPSAiICsgcmVzdG8gKyAiIC8gdmFsb3IgPSAiICsgdmFsb3IgKTsKCQkJbXlBcnJheVtuZGl2aXNvZXMrK10gPSByZXN0bzsKCQl9CgoJCVN0cmluZyBzb21hID0gIiI7CgkJZm9yKCBpbnQgaiA9IG5kaXZpc29lczsgaiA+PSAwOyBqLS0gKXsKCQkJaWYoIG15QXJyYXlbal0gPT0gMSApewoJCQkJU3lzdGVtLm91dC5wcmludCggc29tYSArICIyXiIgKyBqICk7CgkJCQlzb21hID0gIiArICI7CgkJCX0KCQl9Cgl9Cn0=