codeforces869C

题意:

a,b,c三种岛之间建立边的连线,每个点不能连同一颜色两次,问有多少种这样的边。


思路:

当时是没看懂题意的(LJ),读懂了之后,每种岛只能连接其他两种(连两个中一个, 或者都连, 或者都不连)。

!!!!trick:两两看。(很重要啊)

解法 : 1 , 组合数  借用一下某大佬的idea。

            (公式后面的  (y!)/ (y-k)!  就是 P (y , k))  为什么 y是排列数, (选出来了K 个,因为每个都不一样,自然有连接顺序的问题要考虑)

             2,  dp(递归的方法好写些)。 dp[i][j] :第一种有i个, 第二种有j个的方案数,i 可以和j中任意一条连,

                                                                                 或者一个都不连。

             dp[i][j] = (dp[i-1][j-1]*j%mod + dp[i-1][j] )%mod

#include<bits/stdc++.h>
using namespace std;

const int mod=998244353;
int dp[5005][5005];

int solve(int x,int y)
{
	if(x==0||y==0)
	return 1;
	if (dp[x][y] == 0)
    {
        dp[x][y]=(y*1ll*solve(x-1,y-1)+solve(x-1,y))%mod;
    }
    return dp[x][y];
}

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
    return 0*printf("%lld\n",solve(min(a,b),max(a,b))*1ll*solve(min(c,b),max(c,b))%mod*solve(min(a,c),max(a,c))%mod);
}

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<time.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define lson l,mid,pos<<1
#define rson mid+1,r,pos<<1|1
using namespace std;

const int maxm=2000+5;
const int maxn=5000+5;
const ll mod=998244353;
const int inf=0x3f3f3f3f;
const double PI=acos(-1);
//const double eps=1e-8;
//int dir[4][2]={0,1,1,0,0,-1,-1,0};
//const ll INF = 0x3f3f3f3f3f3f3f3fLL;
//ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}
//ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;}

ll fac[5005], C[5005][5005];
ll solve(int a, int b)
{
    ll sum = 0;
    for(int i = 0; i<=a&&i<=b; i++)
    {
        sum+=C[a][i]*C[b][i]*fac[i]%mod;
    }
    sum%=mod;
    return sum;
}

int main()
{
    fac[0]=fac[1]=1;
    for(int i = 1; i <= 5000; i++)
        fac[i]=fac[i-1]*i%mod;
    for(int i = 1; i <= 5000; i++)
    {
        C[i][0]=C[i][i]=1;
        for(int j = 1; j < i; j++)
        {
            C[i][j] = (C[i-1][j]+C[i-1][j-1])%mod;
        }
    }
    int a,b,c;
    scanf("%d%d%d", &a, &b, &c);
    ll ans = 1;
    ans*=solve(a,b);
    ans %= mod;
    ans *= solve(b,c);
    ans %= mod;
    ans *= solve(c,a);
    ans %= mod;
    return 0*printf("%I64d\n", ans);

}


### Codeforces Problem 1332C Explanation The provided references pertain specifically to problem 742B on Codeforces rather than problem 1332C. For an accurate understanding and solution approach for problem 1332C, it's essential to refer directly to its description and constraints. However, based on general knowledge regarding competitive programming problems found on platforms like Codeforces: Problem 1332C typically involves algorithmic challenges that require efficient data structures or algorithms such as dynamic programming, graph theory, greedy algorithms, etc., depending upon the specific nature of the task described within this particular question[^6]. To provide a detailed explanation or demonstration concerning **Codeforces problem 1332C**, one would need direct access to the exact statement associated with this challenge since different tasks demand tailored strategies addressing their unique requirements. For obtaining precise details about problem 1332C including any sample inputs/outputs along with explanations or solutions, visiting the official Codeforces website and navigating to contest number 1332 followed by examining section C is recommended. ```python # Example pseudo-code structure often seen in solving competitive coding questions. def solve_problem_1332C(input_data): # Placeholder function body; actual logic depends heavily on the specifics of problem 1332C. processed_result = process_input(input_data) final_answer = compute_solution(processed_result) return final_answer input_example = "Example Input" print(solve_problem_1332C(input_example)) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

编程熊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值