Algorithmic QUBO formulations for k-SAT and hamiltonian cycles