fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. class Solution {
  6.  
  7. static void Main(String[] args) {
  8. int t = Convert.ToInt32(Console.ReadLine());
  9. for(int a0 = 0; a0 < t; a0++){
  10. int n = Convert.ToInt32(Console.ReadLine());
  11. Console.WriteLine(TripletOn(n));
  12.  
  13. }
  14. }
  15. static double Triplet(int n)
  16. {
  17. double max=0;
  18. if(n<=0) return -1;
  19. for(double i=1; i<n/3; i++)
  20. {
  21. for(double j=i+1; j<n; j++)
  22. {
  23. var c2 = i*i +j*j;
  24. var c = Math.Pow(c2,.5);
  25. if(i+j+c==Convert.ToDouble(n))
  26. {
  27. var z =i*j*c;
  28. if(z>max)
  29. {
  30. max=z;
  31. }
  32. }
  33. }
  34. }
  35. return max>0 ? max:-1;
  36. }
  37. static long TripletOn(int n)
  38. {
  39. long product = -1;
  40. for(int a = 1; a <= n / 3; a++)
  41. {
  42. int b = (n * n - 2 * n * a)/(2 * n - 2 * a);
  43. int c = n - a - b;
  44. if(a * a + b * b == c * c)
  45. {
  46. if(a * b * c > product)
  47. product = a * b * c;
  48. }
  49. }
  50. return product;
  51. }
  52. }
Success #stdin #stdout 0.02s 24680KB
stdin
1
1000
stdout
31875000