Anyway, if x is the number of the first paragraph.
The first paragraph: directly multiply the unit price by X.
Paragraph 2: Add the total cost of the first paragraph and multiply it by the unit price of the second paragraph (the quantity of the second paragraph -X).
Paragraph 3: Similar to the second paragraph, add the total expenses of the first paragraph and the second paragraph, and then multiply the unit price of the third paragraph by (the quantity of the third paragraph-the quantity of the second paragraph -X).
There is no formula.
For the sake of my hard typing, adopt me, dear ~