We do something like this but with extra work.
We bundle the items in groups and list as variations.
If we have 40 of X we pre-bundle them in packs as:
QTY 2 X 10
QTY 4 X 5
Then list as variations with the QTY in the variation and set the price for each variation.
We have the items pre-bundled so that we just pull the corresponding bundle when shipping.