EIU Olympic Final Contest 2024 - E: Snow Tree

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 256M
Input: stdin
Output: stdout

Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

Sol is studying the unique biological function of a species of plant called the Snow Tree on an unnamed planet. After many days of observation, Sol has noticed that the reproductive pattern of the Snow Tree is quite unusual. Specifically, the Snow Tree does not sprout when its seeds are sown. Instead, when certain conditions are met, it appears and exists at a fixed point according to a certain rule, with an initial height of ~a~. After some time, it grows another Snow Tree in front of it with a random height ~b~, and then continues to grow more trees based on the following rule: "The height of any Snow Tree is always the average of the height of the previous tree and the next tree."

Task: Based on the recorded heights of the first two Snow Trees, calculate the height of the ~n~-th Snow Tree.

Input

  • The first line contains two integers: the heights of the first two trees ~a~ and ~b~.
  • The second line contains a positive integer ~n~.

Output

  • Print the height of the ~n~-th Snow Tree.

Sample Input 1

2 3  
4

Sample Output 1

5

Sample Input 2

1 2  
3

Sample Output 2

3

Constraints

  • ~20\%~ of the test cases correspond to ~a, b, n ≤ 10^{18}~.
  • ~60\%~ of the test cases correspond to ~a, b, n ≤ 10^{10^{4}}~.
  • ~20\%~ of the test cases correspond to ~a, b, n ≤ 10^{10^{5}}~.

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.