File size: 1,927 Bytes
c4b0eef |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define MAX 100001
#define mod 1000000007
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
while(true){
int x,y,z;
cin>>x>>y>>z;
if(x==0 && y==0 && z==0){
break;
}
else{
cout<<endl;
}
int d, r;
ll next;
if((y-x)==(z-y)){
// case of AP
d = y-x;
next = z + d;
cout<<"AP "<<next;
continue;
}
else{
// case of GP
if(x>0 && y>0){
if(y<x)//decreasing
{
r = (x/y);
next = (z/r);
}
else // increasing
{
r = (y/x);
next = z*r;
}
}
else if(x<0 && y<0){ // negative numbers
if(y<x){ //increasing in negative numbers
r = (y/x);
next = z*r;
}
else{ // decreasing in negative numbers
r = (x/y);
next = (z/r);
}
}
else{
if(x<0){
if(x<z){
r = x/y;
next = z/r;
}
else{
r = y/x;
next = z*r;
}
}
else{
if(x<z){
r = y/x;
next = z*r;
}
else{
r = y/z;
next = z/r;
}
}
}
cout<<"GP "<<next;
}
}
return 0;
} |