Minecraft wiki entry for Before_1.8, associated text: S is the sacrifice durability, and MaxD is the maximum durability for it's type.
N is an offset for the item type, equal to 100-floor(0.12*MaxD). (This is negative for diamond tools.)
The cost is 1+floor((S-N)/100)