2017山东省赛 Fireworks

Description

Hmz likes to play fireworks, especially when they are put regularly.
Now he puts some fireworks in a line. This time he put a trigger on each firework. With that trigger, each firework will explode and split into two parts per second, which means if a firework is currently in positionx, then in next second one part will be in position x−1 and one inx+1. They can continue spliting without limits, as Hmz likes.
Now there are n fireworks on the number axis. Hmz wants to know after T seconds, how many fireworks are there in position w?


Input

Input contains multiple test cases.
For each test case:

· The first line contains 3 integers n,T,w(n,T,|w|≤105)

· In next n lines, each line contains two integers xi and ci, indicating there are ci fireworks in position xi at the beginning(ci,|xi|≤105).

Output

For each test case, you should output the answer MOD 1000000007.


一开始题意有点理解歪了,于是去网上搜了一下,再对比了一下,才发现是杨辉三角,在t时刻,每个位置烟花的数量符合杨辉三角的数量规律。然而数学太差,对杨辉三角并不熟哭。搜索了一下,杨辉三角第n行m列的值可以表示为 (N)!/((M)!*(N-M)!),因为是同一时间,也就是说N是同一个值,这样就可以写出同一层的递推式。,,,,但是这个时候又有一个问题就是除法取模的问题,要用逆元解决,从来没用过逆元又学习了一下费马小定理。根据网上的资料,(a / b) MOD M = a* b^(M-2) (mod M)。之后的只要讨论一下就可以了。再做几道题用用逆元吧!




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值