Advertisement
Mr_kindle

magicianvikram.c

Oct 26th, 2022 (edited)
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.83 KB | None | 0 0
  1. /*Mr. Vikram is a popular magician and after a long break, his magic shows are now open to the
  2. public again in the theaters. To compensate for the loss in income due to COVID, Mr. Vikram
  3. wants to maximize his profits for every magic show from now on and at the same time, he has
  4. to follow the Covid guidelines set the by government. The guidelines are as follows:
  5.  If two people are seated in the same row, there must be at least one empty seat between
  6. them.
  7.  If two people are seated in different rows, there must be at least one completely empty
  8. row between them.
  9. Given the information about the number of rows and the number of seats in each row, find the
  10. maximum number of tickets Mr. Vikram can sell for his magic show.
  11. Input
  12.  The first line of input will contain a single integer T, denoting the number of test cases.
  13.  Each test case consists of a single line of input containing two integers N, M — the number
  14. of rows and the number of seats in each row, respectively.
  15. Output
  16. For each test case, output – the maximum number of tickets Mr. Vikram can sell.*/
  17.  
  18. /*aLSO available on Pastebin.com*/
  19.  
  20. #include<stdio.h>
  21. #include<stdlib.h>
  22.  
  23. int main()
  24. {   int test_case,n,m,total_ticketsell;
  25.     int non_empty_rows,non_empty_seats;
  26.     printf("Enter number of test cases:  \n");
  27.     scanf("%d",&test_case);
  28.     while(test_case)
  29.     {
  30.        
  31.            
  32.          
  33.  
  34.             test_case--;
  35.         printf("\nPlease enter value of 'N' & 'M' according to question: ");
  36.         scanf("%d %d",&n,&m);
  37.         /*calculating non_empty rows*/
  38.    
  39.             non_empty_rows= n%2 == 0? n/2 : (n+1)/2;
  40.             non_empty_seats= m%2 == 0? m/2 : (m+1)/2;
  41.             total_ticketsell = non_empty_rows * non_empty_seats;
  42.             printf("\nTotal ticket sold = %d ",total_ticketsell);
  43.     }
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement