Codeforces 869 C. The intriguing obsession (combinatorial mathematics) __ Combinatorial mathematics

Source: Internet
Author: User
Tags mul
Description

With hands joined, go everywhere in a speed faster than our thoughts! This time, the Fire Sisters-karen and Tsukihi-is heading for somewhere they ' ve never reached-water-surrounded Island s!

There are three clusters of islands, conveniently coloured red, blue and purple. The clusters consist of a, B and C distinct islands respectively.

Bridges have been built between some (possibly all or none) of the islands. A Bridge bidirectionally connects two different islands and has length 1. For any two islands of the same colour, either they the shouldn ' t being reached from each other through, or the bridges Distance between them is at least 3, apparently in order to prevent oddities from spreading quickly a inside.

The Fire sisters are ready for the unknown, but they ' d also like to test your. And you ' re here to figure out the number of different ways to build all bridges under the constraints, and give the answer Modulo 998 244 353. Two ways are considered different if a pair of islands exist, such that there's a bridge between them in one of them, but Not in the other.

Input

The "I" and "only" of input contains three space-separated integers a, B and C (1≤a, B, c≤5)-the number of Islands in the red, blue and purple clusters, respectively.

Output

Output one line containing a integer-the number of different ways to build bridges, modulo 998244353.

examples Input

1 1 1

examples Output

8

the

To establish bridges between three colors of islands, each color island has a,b,c a,b,c, and the same color of the island between the distance can not be less than 3 3, ask the total number of cases.

train of Thought

Obviously, the arrangement of the final bridge must resemble the abcabcabc ... abcabcabc ... In this way, we abstract the collection of these three color points into a triangular column in space.

Each side is represented by a color, each side with a line (bridge) between the two adjacent sides, apparently guaranteeing the distance between the islands of the same color.

We now consider only one side, if the adjacent two colors have a,b a,b: First, a color can not be associated with the same color, that is, each side of the point between the points can not have a connection. Second, can not have the same two colors of points connected to the same point, that is, the points between the left and right two sides of the line no common starting point and end point, it is obvious that such a side has min (a,b) \min (a,b). Third, the number of bridges is at least 0 0, min (a,b) \min (a,b), for the number I of the bridge, we can choose from the left of the total (AI) \binom{a}{i} ways, from the right to select a total (BI) \binom{b}{i} ways, consider their The arrangement between the total I! I! Species, so altogether (AI) x (BI) xi! \binom{a}{i} \times \binom{b}{i} \times i! kinds of combinations. So for each side, its contribution f (a,b) =∑i=min (a,b) i=0 (AI) (BI) I! F (a,b) =\sum_{i=0}^{i=\min (a,b)}\binom{a}{i}\binom{b}{i}i!.

Because the lines between the three sides are mutually exclusive, the final result is the F (a,b) XF (b,c) XF (c,a) F (a,b) \times f (b,c) \times f (c,a).

AC Code

 #include <bits/stdc++.h> using namespace std; typedef __int64 LL; const int MAXN = 5E3+10;
const int mod = 998244353;
LL MUL[MAXN];

LL INV[MAXN];
    void Init () {mul[0]=1;

    for (int i=1; i<maxn; i++) mul[i]= (mul[i-1]*i)%mod;
    Inv[0]=inv[1]=1;
    for (int i=2; i<maxn; i++) inv[i]= (LL) (mod-mod/i) *inv[mod%i]%mod;
for (int i=1; i<maxn; i++) inv[i]= (inv[i-1]*inv[i))%mod;

LL C (int n,int m) {return mul[n]*inv[m]%mod*inv[n-m]%mod;}
    LL mult (int a,int b) {int len = min (a,b);
    LL ans = 0;
    for (int i=0; i<=len; i++) ans + C (a,i) * C (b,i)% mod * Mul[i]% Mod,ans%= mod;
return ans;
    int32_t Main () {init ();
    int a,b,c;
    cin>>a>>b>>c;
    LL ans = mult (a,b) * mult (b,c)%mod * mult (c,a)%mod;
    cout<<ans<<endl;
return 0; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.