You are given a long enough stick. Your task is to create a new type of foldable ruler something like shown below with it by cutting the stick into pieces and folding them at one point:
You need to have something like above but no mark on it and all sticks are attached at one point and they do not have to have same lengths. You may think each stick as a line and they are sticked at one point for simplicity but it is still foldable so you can measure lengths by folding the rulers. Then By folding the ruler, you are supposed to measure every cm from 1 to 40.
What is the shortest stick length originally you need to have to measure every cm from $1$ to $40$ for this foldable ruler?
For example: if this question was asked for 1 to 8 cm, the answer would be $9$ cm with 1,2,6 cm sticks. So you can measure every cm from 1 to 8 by folding the ruler, such as to measure $8$, fold 2 cm stick to the one side while 6 cm stick to the other side, or to measure $4$ you can fold 2 and 6 in the same side, etc...