欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1077A.Frog Jumping
Frog Jumping
A frog is currently at the point on a coordinate axis . It jumps by the following algorithm: the first jump is units to the right, the second jump is units to the left, the third jump is units to the right, the fourth jump is units to the left, and so on.
Formally:
- if the frog has jumped an even number of times (before the current jump), it jumps from its current position to position ;
- otherwise it jumps from its current position to position .
Your task is to calculate the position of the frog after jumps.
But... One more thing. You are watching different frogs so you have to answer independent queries.
Input
The first line of the input contains one integer () — the number of queries.
Each of the next lines contain queries (one query per line).
The query is described as three space-separated integers () — the lengths of two types of jumps and the number of jumps, respectively.
Output
Print integers. The -th integer should be the answer for the -th query.
Note
In the first query frog jumps to the right, to the left and to the right so the answer is .
In the second query frog jumps to the right, to the left, to the right and to the left so the answer is .
In the third query the answer is .
In the fourth query the answer is .
In the fifth query all frog's jumps are neutralized by each other so the answer is .
The sixth query is the same as the fifth but without the last jump so the answer is .
Samples
6
5 2 3
100 1 4
1 10 5
1000000000 1 6
1 1 1000000000
1 1 999999999
8
198
-17
2999999997
0
1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |