#Q1077A. Frog Jumping
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.
输入格式
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.
输出格式
Print integers. The -th integer should be the answer for the -th query.
样例 #1
样例输入 #1
6
5 2 3
100 1 4
1 10 5
1000000000 1 6
1 1 1000000000
1 1 999999999
样例输出 #1
8
198
-17
2999999997
0
1
提示
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 .