Advertisement
inhuman_Arif

Untitled

Feb 7th, 2022
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.06 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4.  
  5. {
  6.  
  7.     int t,n,bun,patt,chic,price_h,price_c,can_m,have_m,profit,sell_h,sell_c;
  8.  
  9.     scanf("%d",&t);
  10.  
  11.     for(n=0;n<t && t>=1 && t<=100;n++){
  12.  
  13.  
  14.             scanf("%d %d %d",&bun,&patt,&chic);
  15.             scanf("%d %d",&price_h,&price_c);
  16.  
  17.  
  18.             if((price_h>=1) && (price_h<=100)  && (price_c>=1) && (price_c<=100) && (bun>=1) && (bun<=100) &&  (patt>=1) && (patt<=100)  &&  (chic>=1) && (chic<=100))
  19.             {
  20.  
  21.  
  22.  
  23.             if(bun%2!=0){
  24.  
  25.                 can_m=(bun-1)/2;
  26.             }
  27.  
  28.             else if(bun%2==0){
  29.  
  30.                 can_m=bun/2;
  31.             }
  32.  
  33.             have_m=patt+chic;
  34.  
  35.             if(bun==1 || bun==0){
  36.  
  37.                 printf("0\n");
  38.             }
  39.  
  40.             else if(can_m>=have_m){
  41.  
  42.                 profit=(patt*price_h)+(chic*price_c);
  43.  
  44.                 printf("%d\n",profit);
  45.             }
  46.  
  47.             else if(can_m<have_m){                   // solving
  48.  
  49.                 if(price_h<price_c){
  50.  
  51.                     if(can_m>chic){
  52.  
  53.                         sell_h=can_m-chic;
  54.                         sell_c=can_m-sell_h;
  55.  
  56.                         profit=(sell_h*price_h)+(sell_c*price_c);
  57.                         printf("%d\n",profit);
  58.  
  59.                     }
  60.  
  61.                     else if(can_m<=chic){
  62.  
  63.                         sell_c=can_m;
  64.  
  65.                         profit=sell_c*price_c;
  66.                         printf("%d\n",profit);
  67.                     }
  68.                 }
  69.  
  70.                 else if(price_h>price_c){
  71.  
  72.                     if(can_m>patt){
  73.  
  74.                         sell_c=can_m-patt;
  75.                         sell_h=can_m-sell_c;
  76.  
  77.                         profit=(sell_h*price_h)+(sell_c*price_c);
  78.                         printf("%d\n",profit);
  79.  
  80.                     }
  81.  
  82.                     else if(can_m<=patt){       //
  83.  
  84.                         sell_h=can_m;
  85.  
  86.                         profit=sell_h*price_h;
  87.                         printf("%d\n",profit);
  88.                     }
  89.  
  90.  
  91.  
  92.             }
  93.  
  94.  
  95.  
  96.  
  97.  
  98. }
  99.  
  100. }
  101.  
  102.  
  103. }
  104.     return 0;
  105.  
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement