Given integers $a, b, c$ construct a single-tape Turing machine recognizing the language $\{w \in \{0,1\}^{*}: a*\#_{0}w+b*\#_{1}w+c=0\}$ in time $O(n*logn)$, where $n=|w|$. $\#_{x}w$ denotes the number of occurrences of the symbol $x$ in $w$.
Updating counters somewhere on the tape would result in $O(n^2)$ complexity. I suspect extended euclidean algorithm has to be used during construction of this machine.
Make counter using bigger alphabet. In every step move your counter closer to data. So it might look like #•••{counter}{data}B in average step. Adding a or b is O(log n) as well as moving counter one field to the right.
If you want to have counter in one place without moving it every step solution will be O(n^2) like you said as you have to go back to counter every step and it costs O(n) then.
Pozdro ;)