欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1080B.Margarite and the best present
Margarite and the best present
Little girl Margarita is a big fan of competitive programming. She especially loves problems about arrays and queries on them.
Recently, she was presented with an array of the size of elements that is filled as follows:
- And so on ...
That is, the value of the -th element of the array is calculated using the formula .
She immediately came up with queries on this array. Each query is described with two numbers: and . The answer to a query is the sum of all the elements of the array at positions from to inclusive.
Margarita really wants to know the answer to each of the requests. She doesn't want to count all this manually, but unfortunately, she couldn't write the program that solves the problem either. She has turned to you — the best programmer.
Help her find the answers!
Input
The first line contains a single integer () — the number of the queries.
Each of the next lines contains two integers and () — the descriptions of the queries.
Output
Print lines, each containing one number — the answer to the query.
Note
In the first query, you need to find the sum of the elements of the array from position to position . The sum is equal to .
In the second query, you need to find the sum of the elements of the array from position to position . The sum is equal to .
In the third query, you need to find the sum of the elements of the array from position to position . The sum is equal to .
In the fourth query, you need to find the sum of the elements of the array from position to position . The sum is equal to .
In the fifth query, you need to find the sum of the elements of the array from position to position . The sum is equal to .
Samples
5
1 3
2 5
5 5
4 4
2 3
-2
-2
-5
4
-1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |