CF1194F.Crossword Expert
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Today Adilbek is taking his probability theory test. Unfortunately, when Adilbek arrived at the university, there had already been a long queue of students wanting to take the same test. Adilbek has estimated that he will be able to start the test only T seconds after coming.
Fortunately, Adilbek can spend time without revising any boring theorems or formulas. He has an app on this smartphone which contains n Japanese crosswords to solve. Adilbek has decided to solve them all one by one in the order they are listed in the app, without skipping any crossword. For each crossword, a number ti is given that represents the time it takes an average crossword expert to solve this crossword (the time is given in seconds).
Adilbek is a true crossword expert, but, unfortunately, he is sometimes unlucky in choosing the way to solve the crossword. So, it takes him either ti seconds or ti+1 seconds to solve the i-th crossword, equiprobably (with probability 21 he solves the crossword in exactly ti seconds, and with probability 21 he has to spend an additional second to finish the crossword). All these events are independent.
After T seconds pass (or after solving the last crossword, if he manages to do it in less than T seconds), Adilbek closes the app (if he finishes some crossword at the same moment, that crossword is considered solved; otherwise Adilbek does not finish solving the current crossword at all). He thinks it would be an interesting probability theory problem to calculate E — the expected number of crosswords he will be able to solve completely. Can you calculate it?
Recall that the expected value of a discrete random variable is the probability-weighted average of all possible values — in this problem it means that the expected value of the number of solved crosswords can be calculated as E=i=0∑nipi, where pi is the probability that Adilbek will solve exactly i crosswords.
We can represent E as rational fraction QP with Q>0. To give the answer, you should print P⋅Q−1mod(109+7).
今天,阿迪尔别克正在参加概率论考试。不幸的是,当他抵达大学时,已经排起了长长的队伍,许多学生都希望参加同一场考试。阿迪尔别克估计,自己只有在抵达大学 T 秒后才能开始考试。
幸运的是,阿迪尔别克无需复习那些枯燥的定理或公式,也能打发时间。他的智能手机上有一款应用,其中包含 n 道日式填字谜题供他求解。阿迪尔别克决定按应用中所列顺序依次求解全部谜题,且不跳过任何一道。对于第 i 道谜题,给定一个数值 ti,表示一名普通填字谜题专家解出该题所需的时间(单位:秒)。
阿迪尔别克是一位真正的填字谜题专家,但遗憾的是,他有时在选择解题路径时运气不佳。因此,他解出第 i 道谜题所需的时间为 ti 秒或 ti+1 秒,二者等概率发生(即以概率 21 恰好用 ti 秒解出该题;以概率 21 需额外花费 1 秒才能完成该题)。所有这些事件相互独立。
在经过 T 秒后(或在他用少于 T 秒解完最后一道谜题时),阿迪尔别克将关闭该应用(若他在第 T 秒整恰好完成某道谜题,则该谜题视为已解出;否则,他将完全无法完成当前正在求解的谜题)。他认为,计算 E —— 即他能完整解出的谜题数量的期望值 —— 将是一个有趣的概率论问题。你能算出它吗?
回忆一下,离散型随机变量的期望值是其所有可能取值按对应概率加权后的平均值;本题中,即解出谜题数量的期望值可计算为 E=i=0∑nipi,其中 pi 表示阿迪尔别克恰好解出 i 道谜题的概率。
我们可以将 E 表示为最简有理分式 QP,其中 Q>0。作为答案,请输出 P⋅Q−1mod(109+7)。
输入格式
The first line contains two integers n and T (1≤n≤2⋅105, 1≤T≤2⋅1014) — the number of crosswords and the time Adilbek has to spend, respectively.
The second line contains n integers t1,t2,…,tn (1≤ti≤109), where ti is the time it takes a crossword expert to solve the i-th crossword.
Note that Adilbek solves the crosswords in the order they are given in the input without skipping any of them.
第一行包含两个整数 n 和 T(1≤n≤2⋅105,1≤T≤2⋅1014),分别表示填字游戏的数量以及 Adilbek 可用的总时间。
第二行包含 n 个整数 t1,t2,…,tn(1≤ti≤109),其中 ti 表示填字游戏专家解决第 i 个填字游戏所需的时间。
注意:Adilbek 按照输入中给出的顺序依次解决填字游戏,且不会跳过其中任何一个。
输出格式
Print one integer — the expected value of the number of crosswords Adilbek solves in T seconds, expressed in the form of P⋅Q−1mod(109+7).
输出一个整数——Adilbek 在 T 秒内解出的填字游戏数量的期望值,以 P⋅Q−1mod(109+7) 的形式表示。
输入输出样例
输入#1
3 5 2 2 2
输出#1
750000007
输入#2
3 5 2 1 2
输出#2
125000003
说明/提示
The answer for the first sample is equal to 814.
The answer for the second sample is equal to 817.
第一个样例的答案等于 814。
第二个样例的答案等于 817。
输入解题思路,AI测评打分。不知道怎么写?