fork download
  1. /* add your value() based on this code */
  2. #include <stdio.h>
  3.  
  4. int value(int type, int width, int height, int length) {
  5.  
  6. if (type != 79 && type != 47 && type != 29 && type != 82 && type != 26 && type != 22)
  7. return -1;
  8. else if (width <= 0 || height <= 0 || length <= 0)
  9. return -2;
  10. else {
  11. int unit;
  12. switch (type) {
  13. case 79:
  14. unit = 30;
  15. case 47:
  16. unit = 10;
  17. case 29:
  18. unit = 4;
  19. case 82:
  20. unit = 5;
  21. case 26:
  22. unit = 3;
  23. case 22:
  24. unit = 9;
  25. }
  26. int arr[3];
  27. int arr[0] = (width < height)? width : height;
  28. int temp = (width > height)? width : height;
  29. int arr[1] = (temp < length)? temp : length;
  30. int arr[2] = (temp > length)? temp : length;
  31. if (arr[0] > arr[1]) {
  32. temp = arr[0];
  33. arr[0] = arr[1];
  34. arr[1] = temp;
  35. }
  36. int val = arr[0] * arr[0] * arr[0] * (arr[1] / arr[0]) * (arr[2] / arr[0]) * unit;
  37. arr[1] = arr[1] % arr[0];
  38. arr[2] = arr[2] % arr[0];
  39.  
  40.  
  41. return val;
  42. }
  43.  
  44. }
  45.  
  46. int main () {
  47. int type, width, height, length;
  48. scanf ( "%d%d%d%d", &type, &width, &height, &length );
  49. printf ( "%d", value ( type, width, height, length ) );
  50. return 0;
  51. }
Success #stdin #stdout 0.01s 5320KB
stdin
79 4 8 2
stdout
576