Project Euler 849
Project Euler 849
题目
The Tournament
In a tournament there are \(n\) teams and each team plays each other team twice. A team gets two points for a win, one point for a draw and no points for a loss.
With two teams there are three possible outcomes for the total points. \((4,0)\) where a team wins twice, \((3,1)\) where a team wins and draws, and \((2,2)\) where either there are two draws or a team wins one game and loses the other. Here we do not distinguish the teams and so \((3,1)\) and \((1,3)\) are considered identical.
Let \(F(n)\) be the total number of possible final outcomes with \(n\) teams, so that \(F(2) = 3\).
You are also given \(F(7) = 32923\).
Find \(F(100)\). Give your answer modulo \(10^9+7\).
解决方案
任取两队 \(X,Y\)。两场比赛的总得分一定是 \(4\)(每场总得分 \(2\),两场共 \(4\))。并且 \(X\) 在两场中能拿到的总分恰好可以是\(0,1,2,3,4\) (例如:两负得 \(0\),负+平得 \(1\),双平或胜负各一得 \(2\),胜+平得 \(3\),两胜得 \(4\))。因此对每一对队伍 \(\{X,Y\}\),最终只需要知道“这 \(4\) 分如何在两端分配”,也就是一个整数 \(t\in\{0,1,2,3,4\}\): \(X\) 得 \(t\),\(Y\) 得 \(4-t\)。
所以本题等价于:在完全图每条边上,把固定总量 \(4\) 的分数分给两端(允许 \(0\sim 4\) 任意分配),问所有可能的最终总分多重集合数。将这一类问题记为 \(F_j(n)\):每一对的总分固定为 \(j\),端点分配为 \(0\sim j\)。本题就是\(F(n)=F_4(n).\)
对一般的 \(F_j(n)\),设普通生成函数\(\displaystyle\mathcal F_j(x)=\sum_{n\ge 0}F_j(n)x^n, F_j(0)=1.\)定义\(\displaystyle\mathcal G_j(x)=x\frac{\mathcal F_j'(x)}{\mathcal F_j(x)}=\sum_{k\ge1} G_j(k)x^k\)(也就是\(\displaystyle \log \mathcal{F}_j(x)=\sum_{k\ge1} \dfrac{G_j(k)}{k}x^k\))。 比较系数可得(把 \(\mathcal F_j'(x)\) 展开后逐项对齐):\(\displaystyle nF_j(n)=\sum_{k=1}^n F_j(n-k)G_j(k),\)即
\[ F_j(n)=\frac{1}{n}\sum_{k=1}^n F_j(n-k)G_j(k),(n\ge1). \]
对任意 \(j\ge1\),论文给出:
\[ G_j(k)=\frac{1}{(j+1)k}\sum_{d\mid k}(-1)^{(k-d)j}\varphi\left(\frac{k}{d}\right)\binom{(j+1)d}{d}. \]
本题 \(j=4\) 为偶数,符号恒为 \(+1\),因此可简化为
\[ G_4(k)=\frac{1}{5k}\sum_{d\mid k}\varphi\left(\frac{k}{d}\right)\binom{5d}{d}. \]
由此回代,即可得到\(F_4\)的值。
代码
1 | N = 100 |