a town has a population of 20000 people. X % of them are on-legged, and half of the others go barefoot. How many sandals are worn in the town?

Let x = the fraction that are one-legged

x*20000 are one-legged and wear one sandal

0.5(1-x)*20000 go bare foot

0.5(100-x)*20000 wear two sandals

Let S = the number of sandals worn in town:

S = (1 sandal)(20,000)x + (0 sandals)(0.5)(1-x)(20,000) + (2 sandals)(0.5)(1-x)(20,000)

S = 20,000x + 0 + 20,000 - 20,000x

S = 20,000 sandals, or one per citizen

----------

You can actually figure this out logically. X% of the people wear one sandal. Of the remaining people, half wear no sandals, half wear two; so it averages to one sandal per person, just like the x%. So the number of sandals equals the number of people.