102751: [AtCoder]ABC275 B - ABC-DEF

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:12 Solved:0

Description

Score : $200$ points

Problem Statement

There are non-negative integers $A$, $B$, $C$, $D$, $E$, and $F$, which satisfy $A\times B\times C\geq D\times E\times F$.
Find the remainder when $(A\times B\times C)-(D\times E\times F)$ is divided by $998244353$.

Constraints

  • $0\leq A,B,C,D,E,F\leq 10^{18}$
  • $A\times B\times C\geq D\times E\times F$
  • $A$, $B$, $C$, $D$, $E$, and $F$ are integers.

Input

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

$A$ $B$ $C$ $D$ $E$ $F$

Output

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


Sample Input 1

2 3 5 1 2 4

Sample Output 1

22

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


Sample Input 2

1 1 1000000000 0 0 0

Sample Output 2

1755647

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


Sample Input 3

1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000

Sample Output 3

0

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

Input

题意翻译

输入 $A,B,C,D,E,F(0\le A,B,C,D,E,F\le10^{18})$,输出 $(A\times B\times C)-(D\times E \times F) \mod 998244353$

Output

得分:200分

问题描述

存在非负整数$A$、$B$、$C$、$D$、$E$和$F$,满足$A\times B\times C\geq D\times E\times F$。

求$(A\times B\times C)-(D\times E\times F)$除以$998244353$的余数。

约束条件

  • $0\leq A,B,C,D,E,F\leq 10^{18}$
  • $A\times B\times C\geq D\times E\times F$
  • $A$、$B$、$C$、$D$、$E$和$F$是整数。

输入

输入将从标准输入中按照以下格式给出:

$A$ $B$ $C$ $D$ $E$ $F$

输出

将$(A\times B\times C)-(D\times E\times F)$除以$998244353$的余数,作为整数打印。


样例输入1

2 3 5 1 2 4

样例输出1

22

因为$A\times B\times C=2\times 3\times 5=30$,$D\times E\times F=1\times 2\times 4=8$,
所以我们有$(A\times B\times C)-(D\times E\times F)=22$。将这个数除以$998244353$,并打印余数,即$22$。


样例输入2

1 1 1000000000 0 0 0

样例输出2

1755647

因为$A\times B\times C=1000000000$,$D\times E\times F=0$,
所以我们有$(A\times B\times C)-(D\times E\times F)=1000000000$。将这个数除以$998244353$,并打印余数,即$1755647$。


样例输入3

1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000

样例输出3

0

我们有$(A\times B\times C)-(D\times E\times F)=0$。将这个数除以$998244353$,并打印余数,即$0$。

加入题单

上一题 下一题 算法标签: