Skip to content

Instantly share code, notes, and snippets.

@NixImagery
Last active June 27, 2017 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NixImagery/7bb4cca1a07c286bc7162f375098960b to your computer and use it in GitHub Desktop.
Save NixImagery/7bb4cca1a07c286bc7162f375098960b to your computer and use it in GitHub Desktop.
using namespace std;
int main(){
int t;
cin >> t;
for(int a0 = 0; a0 < t; a0++){
int n;
int b, c;
long abc;
long max = -1;
cin >> n;
for (int a = 1; a < (n-5); ++a){
b = (n * (n - (2 * a))) / (2 * (n - a));
c = n - (a + b);
if (a*a + b*b == c*c){
if (b > a){
if (c > b){
abc = a * b * c;
if (abc > max) max = abc;
}
}
}
}
cout << max << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment