本帖最后由 zhangjinxuan 于 2024-2-16 10:14 编辑
现在我们只需要在抽两张牌,所以暴力枚举的算法的时间复杂度为 $O(n^2)$,可以通过。
#include <bits/stdc++.h>
using namespace std;
signed main() {
int tot = 0, win = 0;
for (int i = 1; i <= 49; ++i) {
// 规定其中一张 A 为 1, 另一张为 2
// 规定其中一张 2 为 3,另一张 4,另一张 5
for (int j = 1; j <= 49; ++j) {
if (i == j) continue;
++tot;
if (i == 1 || j == 2 || i == 2 || j == 1) ++win;
else if ((i == 3) + (i == 4) + (i == 5) + (j == 3) + (j == 4) + (j == 5) == 2) ++win;
}
}
int gc = __gcd(win, tot);
win /= gc;
tot /= gc;
printf("%d/%d\n", win, tot);
return 0;
}
输出1/12,虽然很笨,而且不一定对,但是对于我这样的蒟蒻刚刚好
信息学照亮世界! |