# Cutting a cuboid by a diagonal plane.

Suppose we have a cuboid with dimensions $$A\times B\times C$$ composed of $$1\times 1\times 1$$ cubes with $$\gcd(A,B)=gcd(A,C)=gcd(B,C)=1$$.

Considering any vertex of the cuboid as origin, say $$O$$, we select $$3$$ vertices $$P$$,$$Q$$ and $$R$$ such that $$OP$$, $$OQ$$ and $$OR$$ are mutually perpendicular. If we cut the cuboid along the plane $$PQR$$ in two parts, how many $$1\times 1\times 1$$ cubes will be cut?

I have till now solved the problem in $$2D$$ system with a line slicing an $$A\times B$$ rectangle through the diagonal. In that case the answer turns out to be $$A+B-1$$. With similar logic I established that any needle through the diagonal of cuboid will pierce through $$A+B+C-2$$ cubes (correct me if I'm incorrect). But I could not wrap my head around the cuboid and plane problem.

• Why the down-votes? :( Jun 30, 2014 at 19:07
• I don't know, @Prateek, but here's a MathJax tutorial :) Jun 30, 2014 at 19:23
• Thanks @Shaun got it now :) Jun 30, 2014 at 19:34
• Do you mean how many $1 \times 1$ squares on the surface, or how many $1 \times 1 \times 1$ cubes? Jun 30, 2014 at 20:23
• Also, are you sure you don't need $\gcd(A,B)=\gcd(A,C)=\gcd(B,C)=1$? Jun 30, 2014 at 21:47

Let's start with the 2D case. Consider an $A \times B$ rectangle with a line through $(0, A)$ and $(B, 0)$. The line contains all points $(x,y)$ satisfying $Ax+By = AB$. We will say that points $(x,y)$ such that $Ax + By < AB$ are below the line. Notice that there is a one-to-one correspondence between squares intersected by the line, and lattice points on the boundary of the rectangle below the line!
This approach generalizes to $n$ dimensions. For the $A \times B \times C$ cuboid, the answer is:
$(AB+BC+AC-1)/2$