NEW YORK — For decades, people have been getting rid of cockroaches by setting out bait mixed with poison. But in the late 1980s, in an apartment test kitchen in Florida, something went very wrong.


A killer product stopped working. Cockroach populations there kept rising. Mystified researchers tested and discarded theory after theory until they finally hit on the explanation: In a remarkably rapid display of evolution at work, many of the cockroaches had lost their sweet tooth, rejecting the corn syrup meant to attract them.


In as little as five years, the sugar-rejecting trait had become so widespread that the bait had been rendered useless.


“Cockroaches are highly adaptive, and they’re doing pretty well in the arms race with us,” said North Carolina State University entomologist Jules Silverman, discoverer of the glucose aversion in that Florida kitchen during a bait test.


The findings illustrate the evolutionary prowess that has helped make cockroaches so hard to stamp out that it is jokingly suggested they could survive nuclear war.


In a study published Thursday in the journal Science, Silverman and other researchers explain the workings of the genetic mutation that gave some roaches a competitive advantage that enabled them to survive and multiply.


The key is certain neurons that signal the brain about foods.


In normal cockroaches, glucose excites neurons that tell the brain “Sweet!” In the mutant insects, glucose activates neurons that say “Sweet!” and ones that say “Yuck!” The “Yuck!” neurons dampen the signal from the others, so the brain gets the message the taste is awful. This unusual nerve activity appeared in glucose-hating cockroaches collected from Puerto Rico as well as descendants of the Florida insects.


The research focused on the German cockroach, a small kind that can hitch a ride into your home in a grocery bag, not that big lunk known as the American cockroach. Such finicky eating habits have also been seen in these smaller roaches in Southern California, Cincinnati, Indiana, South Korea and Russia. Scientists are now looking to see if other kinds of cockroaches show aversion to glucose.