Bill calculation (very simple math question) I hope this question isn't too simple! If it is, let me know if I should post it elsewhere, thank you. (Also, I didn't know what to tag it with, sorry!)
My wife and I live with my brother-in-law Bob, and, for 30% of the time, also live with Bob's three children.
Our last gas bill was for $161.21 for 45 days.
This is how we work Bob's share of the bill. It seems right but I'm sure there are much simpler ways.
Is this correct?
Is there a more efficient way? (I'm sure there is!)


*

*Total cost (a) divided by number of days (b) = cost per day (c)
            e.g. $161.21/ 45days = $3.58 per day

            c = a/b


*Then calculate how many days the children were here (30%) (y)
            e.g. 30% of 45days = 13.5days

            y = b/100 X 30


*Then calculate how many days the children are not here (z)
            e.g. 45 – 13.5 = 31.5

            z = b - y


*Then find out how much it costs for the amount of days the children are here (d)
            e.g. 13.5 x $3.58 = $48.33

            d = y X c


*Then find out how much per person and times by 4 (Bob + 3 children) (e)
            e.g. ($48.33/ 6 = $8.055) x 4 = $32.22

            e = (d/6) X 4


*Then find out how much Bob owes for the remaining time (f)
            e.g. (31.5 x $3.58 = $112.77) / 3 = $37.59

            f = (z X c) / 3


*Finally, add (e) plus (f):

$32.22 + $37.59 = $69.81



*

*x = e + f
            or:


*x = ((d/6) X 4) + ((z X c) / 3)
            or:


*x = (((y X c)/6) X 4) + (((b - y) X c) / 3)
            or:


*x = ((((b/100 X 30) X c)/6) X 4) + (((b - (b/100 X 30)) X c) / 3)
            or:


*x = ((((b/100 X 30) X (a/b))/6) X 4) + (((b – (b/100 X 30)) X (a/b)) / 3)
            Where:

            a = total cost

            b = number of days

 A: The easiest way, if you wish to distribute equitably, is to compute the number of person-days in the month.
If you, your wife, and Bob all live there 100% of the time, for 45 days in a billing period, that's 135 person-days. If his three kids are there for 14 days each in the billing period, that's another 42 person-days.
Thus, the bill is going to be $\frac{\$161.21}{135+42} = \frac{\$161.21}{177} = \$0.911$ per person-day.
Then, Bob can be attributed 45+42 = 87 person-days.
So his share of the bill is $87 \cdot \$0.911 = \$79.24$.
Edit: updated to reflect 45 day billing period

This process is a standard management/accounting practice. If you've ever done project management, you've almost certainly had to estimate "man-months" or "man-hours". This is the same idea.
When you're computing your bill, if you're a bachelor, you might only be concerned with "dollars per day." Once you start living with more people, then it might be sensible to start looking at "dollars per person per day" or "dollars per day per person". Are these two quantities different? How can we find out?
It turns out that units can be manipulated mathematically through multiplication and division: if you walk 5 meters per 10 seconds, you walk $\frac{5 \textrm{meters}}{10 \textrm{seconds}} = \frac12 \textrm{m/s}$. If you do that for 100 seconds, you multiply: 
$$\require{cancel}
\frac12 \frac{\textrm{meters}}{\cancel{\textrm{seconds}}} \cdot 100 \cancel{\textrm{seconds}} = 50 \textrm{meters}.$$
In your example, if you compute "dollars per person per day", you have
$$\frac{\left(\frac{161.21 \textrm{ dollars}}{N \textrm{ people}}\right)}{45 \textrm{ days}} = \frac{161.21 \textrm{ dollars}}{45N \textrm{ people}\cdot \textrm{days}}.$$
Otherwise, if you compute "dollars per day per person", you have
$$\frac{\left(\frac{161.21 \textrm{ dollars}}{45 \textrm{ days}}\right)}{45 \textrm{ people}} = \frac{161.21 \textrm{ dollars}}{45N \textrm{ people}\cdot \textrm{days}}.$$
These quantities are the same.
Your only challenge is to compute $N$ -- the number of people. Since each kid is only there 30% of the time, they only effectively count as 30% of a person. So your $N$ can be computed as 
$$N = 1_{\textrm{you}} + 1_{\textrm{wife}} + 1_{\textrm{Bob}} + 3\cdot 0.3_{\textrm{kid}} = 3.9$$
Then, now that you can compute "dollars per person-day", you multiply it by each party's attributable person-days: 87 for Bob, 90 for you and your wife. And bam, you get your bill.
(One side note: in my earlier example, I rounded the number of days of kids up to an integer. In this example, 45*0.3 is not an integer number of days, so the result will be different by a handful of cents).
