fork download
  1. using System;
  2.  
  3. namespace CodeStorm
  4. {
  5. class CountingTriangles
  6. {
  7. public static double square(int x)
  8. {
  9. return Math.Pow(x, 2);
  10. }
  11.  
  12. static void Main(string[] args)
  13. {
  14. int n = int.Parse(Console.ReadLine());
  15. string[] A_temp = Console.ReadLine().Split(' ');
  16. int[] A = Array.ConvertAll(A_temp, Int32.Parse);
  17.  
  18. int acute = 0, right = 0, obtuse = 0;
  19. for (int i = 0; i < n - 2; i++)
  20. {
  21. for (int j = i + 1; j < n - 1; j++)
  22. {
  23. int k = j + 1;
  24. while (k < n && A[i] + A[j] > A[k])
  25. {
  26. if (square(A[i]) + square(A[j]) == square(A[k]))
  27. {
  28. right++;
  29. }
  30. else if (square(A[i]) + square(A[j]) > square(A[k]))
  31. {
  32. acute++;
  33. }
  34. else
  35. {
  36. obtuse++;
  37. }
  38. k++;
  39. }
  40. }
  41. }
  42. Console.WriteLine(acute + " " + right + " " + obtuse);
  43. Console.ReadLine();
  44. }
  45. }
  46. }
  47.  
Success #stdin #stdout 0.05s 24000KB
stdin
6
2 3 9 10 12 15
stdout
2 1 4