CF847M Weather Tomorrow
题目描述
`Vasya`想出了一个他自己的天气预报方法。他知道最近$n$天每天的平均气温。假设每天的平均气温是个整数。
`Vasya`相信这$n$天每天的平均气温构成一个等差数列,在这个数列中,第一项是第一天的平均气温,第二项是第二天的平均气温,以此类推。那么第$n+1$天(也就是明天)的平均气温将是这个数列的第$n+1$项。如果这个数列前$n$项并没有他所想的那样是个等差数列,那么按`Vasya`的算法,第$n+1$天的气温将等于第$n$天的气温。
你需要根据`Vasya`的算法求出明天的平均气温。
输入格式
The first line contains a single integer $ n $ ( $ 2
输出格式
Print the average air temperature in the $ (n+1) $ -th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed $ 1000 $ .
说明/提示
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is $ 10 $ and each following terms decreases by $ 5 $ . So the predicted average temperature for the sixth day is $ -10-5=-15 $ .
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is $ 1 $ and each following terms equals to the previous one. So the predicted average temperature in the fifth day is $ 1 $ .
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to $ -5 $ .
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is $ 900 $ and each the following terms increase by $ 100 $ . So predicted average temperature in the third day is $ 1000+100=1100 $ .