>>Is it necessary to grant to Mr X permissions in A and in B in order that he could come to C?
NO!
You could share permission directly to any folder you want to assign Mr X with.
eq:
Mr X
Mr Y
Folder A ------------------- share permission to mr Y (would get A,B,C)
Folder B
Folder C -share permission to mr X (would get C only)
Cheers!