ACPC10A - What’s Next

题意翻译

## 背景: ###### 定义:AP是指等差数列,GP是指等比数列。 例如,序列3、5、7、9、11、13,是以 2 为公差的AP 例如,序列2、6、18、54,是以 3 为公比的GP ## 题目: 给定3个数a1,a2,a3,判断是GP还是AP,并输出下一项。 ## 输入格式: 输入多组a1,a2,a3,以0 0 0结尾。 ## 输出格式: 对于每组a1,a2,a3,判断是GP还是AP并输出,并输出下一项。 ## 样例 ![样例输入输出](https://cdn.luogu.org/upload/pic/19597.png) (本题原样例(格式)有问题) a1,a2,a3都是Int类型 范围:(−10, 000 < a1 , a2 , a3 < 10, 000) 感谢@__CDy 提供的翻译

题目描述

According to Wikipedia, an arithmetic progression (AP) is a sequence of numbers such that the difference of any two successive members of the sequence is a constant. For instance, the sequence 3, 5, 7, 9, 11, 13, . . . is an arithmetic progression with common difference 2. For this problem, we will limit ourselves to arithmetic progression whose common difference is a non-zero integer. On the other hand, a geometric progression (GP) is a sequence of numbers where each term after the first is found by multiplying the previous one by a fixed non-zero number called the common ratio. For example, the sequence 2, 6, 18, 54, . . . is a geometric progression with common ratio 3. For this problem, we will limit ourselves to geometric progression whose common ratio is a non-zero integer. Given three successive members of a sequence, you need to determine the type of the progression and the next successive member.

输入输出格式

输入格式


Your program will be tested on one or more test cases. Each case is specified on a single line with three integers (−10, 000 < a1 , a2 , a3 < 10, 000) where a1 , a2 , and a3 are distinct. The last case is followed by a line with three zeros.

输出格式


For each test case, you program must print a single line of the form: XX v where XX is either AP or GP depending if the given progression is an Arithmetic or Geometric Progression. v is the next member of the given sequence. All input cases are guaranteed to be either an arithmetic or geometric progressions.

输入输出样例

输入样例 #1

\n4 7 10\n2 6 18\n0 0 0\n\n

输出样例 #1

\nAP 13\nGP 54