-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain3.cpp
More file actions
43 lines (34 loc) · 1.17 KB
/
main3.cpp
File metadata and controls
43 lines (34 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
void generateCombinations(vector<int>& currentCombination, int remainingArea, int remainingWidth, int smallestSquare) {
if (remainingArea == 0) {
for (const auto& square : currentCombination) {
cout << square << " ";
}
cout << endl;
return;
}
else if (remainingArea < 0 || remainingWidth == 0) {
return;
}
for (int i = smallestSquare; i <= min(remainingWidth, static_cast<int>(sqrt(remainingArea))); i++) {
currentCombination.push_back(i);
generateCombinations(currentCombination, remainingArea - i * i, min(i, remainingArea - i * i), i);
currentCombination.pop_back();
}
}
void getSquareCombinations(int a, int b, int smallestSquare) {
vector<int> currentCombination;
generateCombinations(currentCombination, a * b, max(a, b), smallestSquare);
}
int main() {
int rectangle_a = 10;
int rectangle_b = 10;
int smallest_square = 2; // Specify the smallest square to be considered
for (int i = 1; i < 201; i++){
getSquareCombinations(i, i, smallest_square);
}
return 0;
}