Calculate $\int_{0}^{1} (x-f(x))^{2016} dx$, given $f(f(x))=x$. This question was asked in an entrance test for an undergraduate mathematics program today, held all over India. 
Question: $f$ is a differentiable function in $[0,1]$ such that $f(f(x))=x$ and $f(0)=1$.
Find the value of $\int_{0}^{1} (x-f(x))^{2016} dx$.
I tried to solve it by substituting $f(f(x))$ in place of $x$, but could not proceed much further. Any hints or solutions will be appreciated.
 A: Let
$$ I = \int_0^1 (x - f(x))^{2016}\, dx $$
Substitute $ x = f(u) $ and note that $ f(0) = 1 $, $ f(1) = 0 $ to obtain
$$ I = \int_1^0 (f(u) - u)^{2016} f'(u)\, du = - \int_0^1 (x - f(x))^{2016} f'(x)\, dx $$
Then,
$$ 2I = I + I = \int_{0}^{1} (x - f(x))^{2016} (1 - f'(x))\, dx $$
and we may substitute $ w = x - f(x) $, $ dw = (1 - f'(x))\, dx $ (noting that $1 - f(1) = 1 $ and $ 0 - f(0) = -1 $) to obtain
$$ 2I = \int_{-1}^{1} w^{2016}\, dw = \frac{2}{2017} $$
and
$$ I = \int_0^1 (x - f(x))^{2016}\, dx = \frac{1}{2017} $$
A: An alternative solution is to note that $f(f(x))=x$ means that $f(x)$ is its own inverse. Geometrically, this means that the function will be perpendicular to the line $y=x$ at the point of intersection and symmetric on each side of $y=x$. Since it is differentiable over $[0,1]$ and we are given that $f(0)=1$, one such function that comes to mind is $f(x)=1-x$. 
Now that a possible function is known, the calculation of the integral is easy:
$$\int_0^1 (x-f(x))^{2016}\,dx=\int_0^1(2x-1)^{2016}\,dx=\frac{1}{2017}$$
