QOJ.ac

QOJ

Time Limit: 0.3 s Memory Limit: 512 MB Total points: 100

#10347. 取球

统计

小A和小B玩一个游戏。小A找了一些数,把它们装进一个袋子里,然后随机拿出一个,让小B猜是多少。小B很快发现猜期望(即这些数的平均数)是最接近的,于是每次都猜期望。小A觉得有些无聊了,于是把游戏增强了,但是小B又很快地发现猜期望最好。

增强了许多次以后,游戏变成了这样:从$2$个袋子里各随机取出一个数,分别记作$m$、$n$,然后小A拿出$m$个球和$n$个袋子,将球都随机放进袋子中,然后再随机找出一个袋子,让小B猜里面有多少个球(小B知道$m$和$n$分别是多少)。现在小A有些好奇,如果小B每次都猜期望,那么猜的“偏差度”是多少呢?小A问你袋子里的实际球数减去小B猜的数的差的$k$次方的期望。

其实,如果设袋子里的实际球数为$x$,那么小A问你的东西叫做变量$x$的$k$阶中心矩,它的定义是$\mathrm{E}\left((x-\mathrm{E}(x))^k\right)$。特别地,2阶中心矩就是方差。

输入格式

输入第一行包含$3$个正整数$N_n$,$N_m$和$N_k$,分别表示取$n$、$m$的袋子的数的种类数和询问个数。

接下来$N_n$行,每行包含两个正整数$n_i$和${num}_{n_i}$,表示取$n$的袋子中有${num}_{n_i}$个$n_i$。

接下来$N_m$行,每行包含两个正整数$m_i$和${num}_{m_i}$,表示取$m$的袋子中有${num}_{m_i}$个$m_i$。

接下来$N_k$行,每行包含一个正整数$k$,表示一次询问。

输出格式

可以证明,答案一定是有理数。共输出$N_k$行,每行一个整数,表示一次询问的答案模$1000000007$($10^9+7$)的结果,即,设答案为$a/b$($a$和$b$为互质的正整数),你输出的整数为$x$,则你需要保证$b \cdot x$与$a$模$1000000007$同余且$0\leq x < 1000000007$。

样例数据

样例输入

1 1 2
3 1
2 1
2
3

样例输出

444444448
481481485

样例说明

设$(a,b,c)$表示$3$个袋子中的球数分别是$a$、$b$、$c$,对于第一个询问,$(2,0,0)$, $(0,2,0)$, $(0,0,2)$的概率都是$1/9$,方差都是$8/9$,$(1,1,0)$, $(1,0,1)$, $(0,1,1)$的概率都是$2/9$,方差都是$2/9$,所以方差的期望是$1/9*8/9*3+2/9*2/9*3=4/9$。$444444448*9$与$4$模$1000000007$同余。

样例输入

2 2 2
3 2
2 1
3 2
2 1
2
3

样例输出

172839508
650205766

样例说明

对于第一个询问,有$4/9$的概率是$3$袋$3$球,方差的期望是$2/3$;有$2/9$的概率是$2$袋$3$球,方差的期望是$3/4$;有$2/9$的概率是$3$袋$2$球,方差的期望是$4/9$;有$1/9$的概率是$2$袋$2$球,方差的期望是$1/2$。所以所求等于$4/9 \times 2/3+2/9 \times 3/4+2/9 \times 4/9+1/9 \times 1/2=50/81$。$172839508 \times 81$与$50$模$1000000007$ 同余。

数据规模和约定

对于全部测试数据,$n_i, m_i \leq {10}^9$,$N_n \leq 5000$,$N_m, k, {num}_{n_i}, {num}_{m_i} \leq 2000$,$N_k \leq 200$。

测试点编号 $k\leq$ $n_i,m_i\leq$ $N_n=$ $N_m=$ $N_k=$
1 1 $7$ 1 1 1
2 2 $7$ 1 1 1
3 2 $30$ 1 1 1
4 2 $30$ 2 2 1
5 2 $10^4$ 1 1 1
6 2 $10^9$ 200 200 1
7 3 $30$ 2 2 2
8 3 $10^4$ 2 2 2
9 3 $10^4$ 200 200 2
10 4 $30$ 2 2 2
11 50 $5 \times 10^6$ 1 1 1
12 50 $10^9$ 2000 50 50
13 50 $10^9$ 50 2000 50
14 50 $10^9$ 2000 2000 50
15 300 $30$ 2 2 2
16 300 $10^9$ 2 2 2
17 300 $10^9$ 200 200 200
18 300 $10^9$ 200 200 200
19 2000 $10^9$ 2 2 2
20 2000 $10^9$ 5000 2 2
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.