fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int gcd(int a, int b)
  5. {
  6. int r;
  7. while (a % b != 0)
  8. {
  9. r = a % b;
  10. a = b;
  11. b = r;
  12. }
  13. return b;
  14. }
  15.  
  16. int leaked(int a)
  17. {
  18. if (a > 2147483647)
  19. return 1;
  20. else
  21. return 0;
  22. }
  23.  
  24. int value(int type, int width, int height, int length)
  25. {
  26. int checktype = 0;
  27. int ref[] = {82, 79, 47, 29, 26, 22};
  28. for (int i = 0; i < 6; i++)
  29. if (type == ref[i])
  30. checktype = 1;
  31. if (!checktype)
  32. return -1;
  33. if (width < 0 || height < 0 || length < 0)
  34. return -2;
  35. int ab = gcd(width, height);
  36. int gcd_3 = gcd(ab, length);
  37. int val = type * width * height * length * pow(gcd_3, 3);
  38. return val;
  39. }
  40.  
  41. int main()
  42. {
  43. int a, b, c, d;
  44. scanf("%d %d %d %d", &a, &b, &c, &d);
  45.  
  46. printf("%d\n", value(a, b, c, d));
  47.  
  48. return 0;
  49. }
  50.  
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
-1