#abc275b. B - ABC-DEF

B - ABC-DEF

Score : 200200 points

问题描述

存在非负整数 AABBCCDDEEFF,满足 A×B×CD×E×FA\times B\times C\geq D\times E\times F

要求解 (A×B×C)(D×E×F)(A\times B\times C)-(D\times E\times F) 除以 998244353998244353 的余数。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are non-negative integers AA, BB, CC, DD, EE, and FF, which satisfy A×B×CD×E×FA\times B\times C\geq D\times E\times F.
Find the remainder when (A×B×C)(D×E×F)(A\times B\times C)-(D\times E\times F) is divided by 998244353998244353.

Constraints

  • 0A,B,C,D,E,F10180\leq A,B,C,D,E,F\leq 10^{18}
  • A×B×CD×E×FA\times B\times C\geq D\times E\times F
  • AA, BB, CC, DD, EE, and FF are integers.

Input

The input is given from Standard Input in the following format:

AA BB CC DD EE FF

Output

Print the remainder when (A×B×C)(D×E×F)(A\times B\times C)-(D\times E\times F) is divided by 998244353998244353, as an integer.

Sample Input 1

2 3 5 1 2 4

Sample Output 1

22

Since A×B×C=2×3×5=30A\times B\times C=2\times 3\times 5=30 and D×E×F=1×2×4=8D\times E\times F=1\times 2\times 4=8,
we have (A×B×C)(D×E×F)=22(A\times B\times C)-(D\times E\times F)=22. Divide this by 998244353998244353 and print the remainder, which is 2222.

Sample Input 2

1 1 1000000000 0 0 0

Sample Output 2

1755647

Since A×B×C=1000000000A\times B\times C=1000000000 and D×E×F=0D\times E\times F=0,
we have (A×B×C)(D×E×F)=1000000000(A\times B\times C)-(D\times E\times F)=1000000000. Divide this by 998244353998244353 and print the remainder, which is 17556471755647.

Sample Input 3

1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000

Sample Output 3

0

We have (A×B×C)(D×E×F)=0(A\times B\times C)-(D\times E\times F)=0. Divide this by 998244353998244353 and print the remainder, which is 00.

update @ 2024/3/10 11:34:37