欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2025B.Binomial Coefficients, Kind Of
Binomial Coefficients, Kind Of
Recently, akshiM met a task that needed binomial coefficients to solve. He wrote a code he usually does that looked like this:
for (int n = 0; n < N; n++) { // loop over n from 0 to N-1 (inclusive)
C[n][0] = 1;
C[n][n] = 1;
for (int k = 1; k < n; k++) // loop over k from 1 to n-1 (inclusive)
C[n][k] = C[n][k - 1] + C[n - 1][k - 1];
}
Unfortunately, he made an error, since the right formula is the following:
C[n][k] = C[n - 1][k] + C[n - 1][k - 1]
But his team member keblidA is interested in values that were produced using the wrong formula. Please help him to calculate these coefficients for various pairs . Note that they should be calculated according to the first (wrong) formula.
Since values may be too large, print them modulo .
Input
The first line contains a single integer () — the number of pairs. Next, pairs are written in two lines.
The second line contains integers ().
The third line contains integers ().
Output
Print integers modulo .
Samples
7
2 5 5 100000 100000 100000 100000
1 2 3 1 33333 66666 99999
2
4
8
2
326186014
984426998
303861760
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |