题意.
三组岛屿,要求在岛屿间建桥,每一个桥距离为1.但是每一种建法,必须满足两个同组的岛屿要不就不可达,要不最短距离至少为3.
思路.
考虑到不可出现同组岛屿间有任何桥,所以仅考虑不同组岛屿的情况.
又不能出现两个同组间距离为2的情况,也就是,不可有任意两同组岛屿连在同一岛上.那么,考虑a,b两组岛屿,要使他们之间满足要求,(假设a < b),只需计算A(b,i)*C(a,i)(i=0,1,…,a)的总和即可.也就是从a中选择i个岛屿来建立到b的桥梁,而b中也仅仅能有i个岛接受,(不可能有任何一座岛,接着两个桥).这个排列应该是容易理解的.
存两个模版,一个是此题用的杨辉三角,一个是卢卡斯的.
/* xzppp */
#include <iostream>
#include <vector>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <queue>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <iomanip>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
#define FFF freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define MP make_pair
#define PB push_back
#define _ %MOD
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int > pii;
typedef pair<LL,LL> pll;
typedef pair<double,double > pdd;
typedef pair<double,int > pdi;
const int MAXM = 2e3+17;
const int MAXV = 2*1e3+17;
const int BIT = 15+3;
const int INF = 0x7fffffff;
const LL INFF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 998244353;
const int MAXN = 5e3+17;
LL C[MAXN][MAXN];
void comb(LL n, LL m, LL p)
{
memset(C, 0, sizeof(C));
C[0][0] = 1;
for(int i = 0; i <= n; i++)
{
C[i][0] = C[i][i] = 1;
for(int j = 1; j < i; j++)
C[i][j] = (C[i-1][j-1] + C[i-1][j]) % p;
}
}
LL perm(LL n,LL m)
{
LL c = C[n][m],d = 1;
for (int i = 1; i <= m; ++i)
d = (d*i)%MOD;
LL res = (c*d)%MOD;
return res;
}
int main()
{
#ifndef ONLINE_JUDGE
FFF
#endif
comb(5000, 5000, MOD);
vector<LL > vec(3);
cin>>vec[0]>>vec[1]>>vec[2];
sort(vec.begin(), vec.end());
LL a,b,c;
a = b = c = 0;
for (int i = 0; i <= vec[0]; ++i)
{
a = (a+(perm(vec[1],i)*C[vec[0]][i])_)_;
c = (c+(perm(vec[2],i)*C[vec[0]][i])_)_;
}
for (int i = 0; i <= vec[1]; ++i)
b = (b+(perm(vec[2],i)*C[vec[1]][i])_)_;
cout<<((a*b)_*c)_<<endl;
return 0;
}
/* xzppp */
#include <iostream>
#include <vector>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <queue>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <iomanip>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
#define FFF freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define MP make_pair
#define PB push_back
#define _ %MOD
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int > pii;
typedef pair<LL,LL> pll;
typedef pair<double,double > pdd;
typedef pair<double,int > pdi;
const int MAXM = 2e3+17;
const int MAXV = 2*1e3+17;
const int BIT = 15+3;
const int INF = 0x7fffffff;
const LL INFF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 998244353;
const int MAXN = 2e4+17;
LL qm(LL a, LL b)
{
LL ans = 1;
a %= MOD;
while(b)
{
if(b & 1)
{
ans = ans * a % MOD;
b--;
}
b >>= 1;
a = a * a % MOD;
}
return ans;
}
LL comb(LL n, LL m)
{
if(m > n) return 0;
LL ans = 1;
for(int i=1; i<=m; i++)
{
LL a = (n + i - m) % MOD;
LL b = i % MOD;
ans = ans * (a * qm(b, MOD-2) % MOD) % MOD;
}
return ans;
}
LL Lucas(LL n, LL m)
{
if(m == 0) return 1;
return comb(n % MOD, m % MOD) * Lucas(n / MOD, m / MOD) % MOD;
}
LL perm(LL n,LL m)
{
LL c = comb(n,m),d = 1,res;
for (int i = 1; i <= m; ++i)
d = (d*i)%MOD;
res = (c*d)%MOD;
return res;
}
int main()
{
#ifdef GoodbyeMonkeyKing
FFF
#endif
return 0;
}
反思.
我特么是真的好笨啊,这题想了那么久,一直在想剪去不可行情况,留下可行情况,搞各种容斥,也没什么其他理由了,就是蠢吧.