카타 8급 Pythagorean Triple

C++[ | ]

bool PythagoreanTriple(const int a, const int b, const int c)
{
  int a2=a*a, b2=b*b, c2=c*c;
  if( a2==b2+c2 ) return true;
  if( b2==c2+a2 ) return true;
  if( c2==a2+b2 ) return true;
  return false;
}
bool PythagoreanTriple(const int a, const int b, const int c)
{
  int max = std::max({a, b, c});
  return a*a + b*b + c*c == max*max*2;
}
bool PythagoreanTriple(const int a, const int b, const int c)
{
  return a*a + b*b == c*c || b*b + c*c == a*a || c*c + a*a == b*b;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}