Website Summary Files Commits Branches @commit @diff @stats
path: root / Week13 / Exercise11.cpp
diff options
context:
space:
mode:
Commit5c3b97fb2572ce8940439abd0652d2a7f7a623bd (patch)
Author
 Syndamia <kamen@syndamia.com>
2026-01-11 13:43:39 +0200
Committer
 Syndamia <kamen@syndamia.com>
2026-01-11 13:43:39 +0200
Filesc122f6fba2c8ac11ea022cc4b63fa89798994915 /Week13/Exercise11.cpp
upp-2025-solutions-5c3b97fb2572ce8940439abd0652d2a7f7a623bd.tar
upp-2025-solutions-5c3b97fb2572ce8940439abd0652d2a7f7a623bd.tar.gz
upp-2025-solutions-5c3b97fb2572ce8940439abd0652d2a7f7a623bd.zip
Parent3c427559e32750c40bbd0d95b525ea42e3b37fc7 (diff)
feat(Week13): Add solutions to most exercises
1 files changed, 26 insertions, 0 deletions
-rw-r--r--Week13/Exercise11.cpp26
diff --git a/Week13/Exercise11.cpp b/Week13/Exercise11.cpp
new file mode 100644
index 0000000..2f29d38
--- /dev/null
+++ b/Week13/Exercise11.cpp
@@ -0,0 +1,26 @@
+#include <iostream>
+
+void threeChildren(unsigned a, unsigned b, unsigned c, unsigned prod) {
+ if (a * b * c == prod) {
+ std::cout << a << ' ' << b << ' ' << c << std::endl;
+ return;
+ }
+
+ if (b + 1 < c - 1)
+ threeChildren(a, b + 1, c - 1, prod);
+ if (b + 1 < c - 2)
+ threeChildren(a + 1, b + 1, c - 2, prod);
+}
+
+void threeChildren(unsigned sum, unsigned prod) {
+ threeChildren(1, 1, sum - 2, prod);
+}
+
+int main() {
+ unsigned sum, prod;
+ std::cin >> sum >> prod;
+
+ threeChildren(sum, prod);
+
+ return 0;
+}