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)。之后的只要讨论一下就可以了。再做几道题用用逆元吧!
本文介绍了一种基于杨辉三角原理的烟花爆炸模拟算法。通过解析题目,我们了解到在特定时间点,烟花的位置分布遵循杨辉三角的规律。文章还讨论了如何处理取模运算中的除法问题,介绍了使用逆元及费马小定理来解决这一难题。
1068

被折叠的 条评论
为什么被折叠?



