9031: Famished Felbat

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

Suppose you are playing Balegrounds. Currently, you have n demons on the board, and there are m. minions in the tavern. You alsohave the effect of Famished Felbat equipped. You have no coins left, so you must end the turn. You wonder what the expectedstrength of your warband is after you end the turn
For the purposes of this problem, we make a few simplifications and specifications as follows:


We assume that each minion is associated with a sindle positive intecer, denoting its stat, When a minion with stat 2: consumesanother minion with stat y, its stat becomes 2 - y, and the consumed minion disappears.
When you have the efect of Famished Felbat equipped, at the end of your tur, the following happens: Each of your minionsorderina from left to right, seauentially chooses a remaining minion in the tavern uniformly at random and consumes it.
The strength f(x) of a minion with stat 2 is defined as follows: f(x)Δ=1/L* sum(k=1~L)[x/k]  ,where L is some given parameter. (Thisformula sets strength of a minion with stat  as the expected number of hits a minion with health a can take, assuming the attackof the opponent's minion is uniformly chosen from [1, L], in the language of real Battleground games,) The strength of yourwarband is the sum of the strengths over all your minions.


Formally, you have n minions with stats a1, 2, ... , an from left to right, respectively. There are m (n < m) minions in the taverrwith stats b1, b2, ... , bm, respectively. You are also given the parameter L. At the end of your tum, the following process happens?


1. Let S be a set initially set as S = (1, 2, ... , m , denoting the indices of remaining minions in the tavern.
2. For i - 1, 2, ..., n, the following happens:


An index 2 is chosen from S uniformly at random, then set a <-- ai + bx and S <-- S/{x}.


3. The strength of your warband is calculated as ∑i=1~n f(ai),   where f(x) is already defined in the statement above.


You need to calculate the expected strength of your warband after the process above.

输入格式

The first line contains three integers n,m,L (1≤n≤m≤1000,1≤L≤2⋅109,L≢0(mod998244353)), denoting the number of your minions, the number of minions in the tavern, and the parameter for calculating the strength, respectively.
The next line contains n integers a1,...,an(1≤ai≤109), denoting the stats of your minions.
The next line contains m integers b1,...,bm(1≤bi≤109), denoting the stats of the minions in the tavern.

输出格式

For each test case, output an integer in a line, denoting the expected strength of your warband after you end the turn. Under the input constraints of this problem, it can be shown that the answer can be written as P/Q , where  and  are coprime integers and Q≢0(mod998244353) . You need to output P⋅Q−1mod998244353  as an answer, where Q−1  is the modular inverse of  with respect to 998244353.

输入样例 复制

3 3 5
1 2 4
3 5 7

输出样例 复制

133099258