You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
591 B
22 lines
591 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
int n = 9;
|
|
const int INF = 0x3f3f3f3f;
|
|
int res = INF, a1, b1, c1;
|
|
int main() {
|
|
int a, b, c;
|
|
for (a = 1; a <= n; a++)
|
|
for (b = a; b <= n; b++)
|
|
for (c = b; c <= n; c++) {
|
|
if (n == a * b * c) {
|
|
if (b - a + c - b + c - a < res) {
|
|
res = b - a + c - b + c - a;
|
|
a1 = a, b1 = b, c1 = c;
|
|
}
|
|
}
|
|
}
|
|
|
|
cout << "a=" << a1 << ",b=" << b1 << ",c=" << c1 << endl;
|
|
return 0;
|
|
} |