Skip to content

Instantly share code, notes, and snippets.

@myguaguagua
Last active August 10, 2018 08:06
Show Gist options
  • Save myguaguagua/113c672c0144a9fdd79429de9df348fd to your computer and use it in GitHub Desktop.
Save myguaguagua/113c672c0144a9fdd79429de9df348fd to your computer and use it in GitHub Desktop.
学妹的思考题
#include <iostream>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
int max_xyz = -1;
for (int x = 1; x < n; x++) {
if (n % x == 0) {
for (int y = x; y < n; y++) {
if (n % y == 0) {
int z = n - x - y;
if (z == 0) {
continue;
}
if (n % z == 0) {
int xyz = x * y * z;
if (xyz > max_xyz) {
max_xyz = xyz;
}
}
}
}
}
}
cout << max_xyz << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment