fork(1) download
  1. #include<stdio.h>
  2. int main() {
  3. int a,b,c;
  4. scanf("%d%d%d",&a,&b,&c);
  5. while(a!=0 || b!=0 || c!=0)
  6. {
  7. if(a>=b && a-b==b-c) //Decreasing AP
  8. {
  9. printf("AP ");
  10. printf("%d\n",c+(a-b));
  11. }
  12. if (a<b && b-a==c-b) //Increasing AP
  13. {
  14. printf("AP ");
  15. printf("%d\n",c+(b-a));
  16. }
  17. else
  18. {
  19. int r;
  20. if(a>b)
  21. {
  22. if(b!=0) r=a/b;
  23. else if(c!=0)
  24. r=b/c;
  25. printf("GP ");
  26. printf("%d\n",c/(r));
  27. }
  28. else if(a<b)
  29. {
  30. if(a!=0)
  31. r=b/a;
  32. else if(b!=0)
  33. r=c/b;
  34. printf("GP ");
  35. printf("%d\n",a*(r*r*r));
  36. }
  37. }
  38. scanf("%lld%lld%lld",&a,&b,&c);
  39. }
  40. return 0;
  41. }
Runtime error #stdin #stdout 0s 3300KB
stdin
2 -4 8
2 6 18
0 0 0
stdout
Standard output is empty