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 l, int b){return l / __gcd(l, b) * b / __gcd(l, b);}int main(){int l = 6;int b = 9;cout << restaurant(l, b) << "\n";return 0;}
No comments:
Post a Comment