問題一覧 > 通常問題

No.538 N.G.S.

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 240
作問者 : Tawara / テスター : yuppe19 😺
お気に入りにしたユーザー ProblemId : 1015 / 自分の提出
問題文最終更新日: 2026-06-25 05:50:07
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 168 (順位表) の他の問題:

Problem Statement

N.G.S. (Number Generator Syndrome) is a disease that affects people who have solved too many recurrence relations.
A person with this disease will, at the slightest trigger, keep saying numbers according to some recurrence relation.
This symptom is also known as sequence hiccups, and it can be stopped by saying the next number for them.

Your friend also has N.G.S. and is having sequence hiccups right now.
From the look on your friend's face, you have realized that the recurrence relation your friend is following has the form

$a_{n+1} = r \ a_n + d$ ( $r,d$ are real numbers)

.

Say the number your friend will say next before they do, and stop the sequence hiccups.

Input

$b_1 \ b_2 \ b_3$

The first line contains the last three numbers of the sequence your friend has said, separated by spaces.
All inputs are integers and satisfy the following constraints.

$-10^5 \le b_1, b_2, b_3 \le 10^5, \ b_1 \neq b_2, \ b_2 \neq b_3$

It is also guaranteed that the number your friend will say next is an integer.

Output

Output the number your friend will say next as an integer. Print a newline at the end.

Sample

Sample 1
Input
1 2 3
Output
4

In this case, $r = d = 1$, and the next number is 4.

Sample 2
Input
2 4 8
Output
16

In this case, $r=2, d = 0$, and the next number is 16.

Sample 3
Input
3 -2 8
Output
-12

The answer may be negative.

Sample 4
Input
21 9 3
Output
0

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。