CF328A.IQ Test
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Petya is preparing for IQ test and he has noticed that there many problems like: you are given a sequence, find the next number. Now Petya can solve only problems with arithmetic or geometric progressions.
Arithmetic progression is a sequence a1 , a1+d , a1+2d , ... , a1+(n−1)d , where a1 and d are any numbers.
Geometric progression is a sequence b1 , b2=b1q , ... , bn=bn−1q , where b1=0 , q=0 , q=1 .
Help Petya and write a program to determine if the given sequence is arithmetic or geometric. Also it should found the next number. If the sequence is neither arithmetic nor geometric, print 42 (he thinks it is impossible to find better answer). You should also print 42 if the next element of progression is not integer. So answer is always integer.
输入格式
The first line contains exactly four integer numbers between 1 and 1000, inclusively.
输出格式
Print the required number. If the given sequence is arithmetic progression, print the next progression element. Similarly, if the given sequence is geometric progression, print the next progression element.
Print 42 if the given sequence is not an arithmetic or geometric progression.
输入输出样例
输入#1
836 624 412 200
输出#1
-12
输入#2
1 334 667 1000
输出#2
1333
说明/提示
This problem contains very weak pretests!