0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ABC385Aをjavascriptで解いた

Posted at

今日の問題

↑押してください。

自分の回答(javascript)

function Main(input){
  min = 1e18
  max = -1e18
  let abc = "abcdefghijklmnopqrstuvwxyz".split("")
  let ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("")
  let f = 1
  if(f == 0){
    input = parseInt(input.trim())
  }
  if(f == 1){
    input = input.trim().split(" ").map((a)=>parseInt(a))
  }
  if(f == 2){
    input = input.trim().split("\n").map((a)=>a.split(" ").map((b)=>parseInt(b)))
  }
  if(f == 3){
    input = input.trim().split("\n")
  }
  //ここより上は定型文です。
  input.sort((a,b)=>a-b)
  
  if(input[2] == input[1]+input[0]||(input[1] == input[2] && input[1] == input[0])){
    console.log("Yes")
  }else{
    console.log("No")
  }
}
Main(require("fs").readFileSync(0, "utf8"));

工夫した点

条件に合うのは3つがすべて同じ数か、一番大きい数とその他の2つの数の和が等しいときであるため、sortしてから比べると簡単に求めることができます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?