Fitting circles

You are given a rectangle of length a and width b. You are required to determine a circle that contains the maximum circumference that fits inside the rectangle. This type of circle is called a big circle. Your task is to determine the maximum number of big circles that can fit inside the rectangle. 

Example:

Input:  a = 40, b = 10
Output: 4

Approach

C++

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

long long fittingCircles(long long along long b)
{

    if (a > b)
        return a / b;
    else
        return b / a;
}
int main()
{

    long long a = 40b = 10;

    cout << fittingCircles(ab<< "\n";

    return 0;
}


No comments:

Post a Comment