Balls of Three Colors

시간 제한2초메모리 제한2048 MB

요약
빨간 공 r개, 초록 공 g개, 파란 공 b개를 일렬로 나열할 때 이웃한 두 공의 색이 다른 배열의 수를 998244353으로 나눈 나머지를 구한다. 각 개수는 1 이상 100000 이하다.
난이도

어려움10점 중 8점

유형
조합론, 동적 계획법, 수학, 누적 합
정답자
아직 제출이 없습니다

문제

There are rr red, gg green, and bb blue balls. How many ways are there to arrange all these balls in a row such that any two adjacent balls have different colors? Since this number can be very large, output its remainder when divided by the prime number 998,244,353998\\,244\\,353.

입력

You are given three integers separated by spaces: rr, gg, and bb. Each of the integers is from 11 to 10510^5 inclusive.

출력

Output a single integer: the required number of ways modulo 998,244,353998\\,244\\,353.

예제3

  1. 예제 1

    입력
    1 1 1
    
    예상 출력
    6
    
  2. 예제 2

    입력
    4 1 1
    
    예상 출력
    0
    
  3. 예제 3

    입력
    1 1 2
    
    예상 출력
    6