Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Mr. Vikram is a popular magician and after a long break, his magic shows are now open to the
- public again in the theaters. To compensate for the loss in income due to COVID, Mr. Vikram
- wants to maximize his profits for every magic show from now on and at the same time, he has
- to follow the Covid guidelines set the by government. The guidelines are as follows:
- If two people are seated in the same row, there must be at least one empty seat between
- them.
- If two people are seated in different rows, there must be at least one completely empty
- row between them.
- Given the information about the number of rows and the number of seats in each row, find the
- maximum number of tickets Mr. Vikram can sell for his magic show.
- Input
- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of a single line of input containing two integers N, M — the number
- of rows and the number of seats in each row, respectively.
- Output
- For each test case, output – the maximum number of tickets Mr. Vikram can sell.*/
- /*aLSO available on Pastebin.com*/
- #include<stdio.h>
- #include<stdlib.h>
- int main()
- { int test_case,n,m,total_ticketsell;
- int non_empty_rows,non_empty_seats;
- printf("Enter number of test cases: \n");
- scanf("%d",&test_case);
- while(test_case)
- {
- test_case--;
- printf("\nPlease enter value of 'N' & 'M' according to question: ");
- scanf("%d %d",&n,&m);
- /*calculating non_empty rows*/
- non_empty_rows= n%2 == 0? n/2 : (n+1)/2;
- non_empty_seats= m%2 == 0? m/2 : (m+1)/2;
- total_ticketsell = non_empty_rows * non_empty_seats;
- printf("\nTotal ticket sold = %d ",total_ticketsell);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement