fork(2) download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int x;
  5.  
  6.  
  7. int numb_stones = 7;
  8. int numb_piles = 3;
  9. long total_combination_number;
  10. volatile int first_pile_price=0;
  11. volatile int second_pile_price=0;
  12. volatile int third_pile_price=0;
  13. int flg_frf;
  14. volatile int i,j,n,kk=1;
  15. volatile int p1,p2,p3;
  16. int jkl;
  17. int total_pile_price[100];
  18. int minprice = 9999;
  19.  
  20. //--------
  21. const int a_data[7][2] = {
  22. {9, 15},
  23. {12, 16},
  24. {16, 13},
  25. {18, 13},
  26. {31, 11},
  27. {32, 1},
  28. {36, 9} };
  29. //----
  30.  
  31.  
  32. if(flg_frf==0)
  33. {
  34. flg_frf=1;
  35.  
  36.  
  37. for(i=0;i<numb_stones-numb_piles+1;i++)
  38. {
  39.  
  40. for(j=i+1;j<numb_stones-numb_piles+2;j++)
  41. {
  42. for(n=j+1+1;n<numb_stones-numb_piles+3;n++)
  43. {
  44. third_pile_price += a_data[n][1]*(a_data[n][0]-a_data[j+1+1][0]);
  45. }
  46. ///obrabotka na informaciqta
  47. total_pile_price[kk] = third_pile_price + second_pile_price + first_pile_price;
  48. x = total_pile_price[kk];
  49. printf("%d\n", x);
  50.  
  51. if(total_pile_price[kk]<minprice)
  52. {
  53. minprice = total_pile_price[kk];
  54. p1 = i;
  55. p2 = j;
  56. p3 = j+1;
  57.  
  58.  
  59. }
  60. kk++;
  61. ///
  62.  
  63.  
  64.  
  65. third_pile_price = 0;
  66. second_pile_price += a_data[j][1]*(a_data[j][0]-a_data[i+1][0]);
  67. }
  68. second_pile_price = 0;
  69. first_pile_price += a_data[i][1]*(a_data[i][0]-a_data[0][0]);
  70.  
  71. }
  72.  
  73.  
  74.  
  75. }
  76.  
  77.  
  78. x = p1;
  79. printf("%d\n", x);
  80. x = p2;
  81. printf("%d\n", x);
  82.  
  83. x = p3;
  84. printf("%d\n", x);
  85.  
  86. return 0;
  87. }
Success #stdin #stdout 0s 10320KB
stdin
1
2
10
42
11
stdout
319
46
88
130
339
46
36
26
191
84
48
191
139
139
256
1
4
5