Problem

Source: 2018 Brazil 4th TST Day 1 #1

Tags: combinatorics, number theory, Sets



Let $n \ge 1$ be an integer. For each subset $S \subset \{1, 2, \ldots , 3n\}$, let $f(S)$ be the sum of the elements of $S$, with $f(\emptyset) = 0$. Determine, as a function of $n$, the sum $$\sum_{\mathclap{\substack{S \subset \{1,2,\ldots,3n\}\\ 3 \mid f(S)}}} f(S)$$where $S$ runs through all subsets of $\{1, 2,\ldots, 3n\}$ such that $f(S)$ is a multiple of $3$.