Algorithm
problem Link : https://www.codechef.com/problems/BURGERS
Problem
Chef is fond of burgers and decided to make as many burgers as possible.
Chef has patties and buns. To make burger, Chef needs patty and bun.
Find the maximum number of burgers that Chef can make.
Input Format
- The first line of input will contain an integer — the number of test cases. The description of test cases follows.
- The first and only line of each test case contains two space-separated integers and , the number of patties and buns respectively.
Output Format
For each test case, output the maximum number of burgers that Chef can make.
Constraints
Sample 1:
4 2 2 2 3 3 2 23 17
2 2 2 17
Explanation:
Test case : Chef has patties and buns, and therefore Chef can make burgers.
Test case : Chef has patties and buns. Chef can make at most burgers by using patties and buns.
Test case : Chef has patties and buns. Chef can make at most burgers by using patties and buns.
Test case : Chef has patties and buns. Chef can make at most burgers by using patties and buns.
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include<stdio.h>
int main(void) {
int t,p,b;
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&p,&b);
if(p>b) printf("%d\n",b);
else printf("%d\n",p);
}
return 0;
}
Copy The Code &
Try With Live Editor
Input
2 2
2 3
3 2
23 17
Output
2
2
17
Demonstration
CodeChef solution BURGERS - Burgers Codechef solution in C,C++