Restaurant

Martha is interviewing at Subway. One of the rounds of the interview requires her to cut a bread of size  into smaller identical pieces such that each piece is a square having maximum possible side length with no leftover piece of bread.

Example:

Input:  l = 6, b = 9
Output: 6

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int restaurant(int lint b)
{
    return l / __gcd(lb) * b / __gcd(lb);
}

int main()
{

    int l = 6;
    int b = 9;

    cout << restaurant(lb<< "\n";

    return 0;
}


No comments:

Post a Comment