
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Maximum of Smallest Possible Area with K Cuts of Given Rectangle in C++
In this tutorial, we will be discussing a program to find the maximum of smallest possible area that can get with exactly k cut of given rectangular.
For this we will be provided with the sides of the rectangle and the number of cuts that can be made. Our task is to calculate the smallest area that can be achieved by making the given number of cuts.
Example
#include <bits/stdc++.h> using namespace std; void max_area(int n, int m, int k) { if (k > (n + m - 2)) cout << "Not possible" << endl; else { int result; if (k < max(m, n) - 1) { result = max(m * (n / (k + 1)), n * (m / (k + 1))); } else { result = max(m / (k - n + 2), n / (k - m + 2)); } cout << result << endl; } } int main() { int n = 3, m = 4, k = 1; max_area(n, m, k); return 0; }
Output
6
Advertisements