結果

問題 No.3054 ほぼ直角二等辺三角形
ユーザー neetprogrammerneetprogrammer
提出日時 2020-05-21 03:21:24
言語 JavaScript
(node v21.7.1)
結果
WA  
実行時間 -
コード長 593 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 6,944 KB
実行使用メモリ 49,436 KB
最終ジャッジ日時 2024-04-21 03:38:09
合計ジャッジ時間 6,669 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 71 ms
39,424 KB
testcase_02 AC 70 ms
39,168 KB
testcase_03 AC 72 ms
42,880 KB
testcase_04 AC 76 ms
43,264 KB
testcase_05 AC 88 ms
44,032 KB
testcase_06 AC 92 ms
44,032 KB
testcase_07 AC 394 ms
44,032 KB
testcase_08 AC 1,231 ms
44,160 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

function f(a) {
  return (2 * (a * a)) + (2 * a) + 1
}

function check(a, c) {
  var b = (a + 1);
  var temp = (a * a) + (b * b);

  if (temp === (c * c))
    return true;
  return false;
}


function Main(input) {
  var loop = Math.pow(10, input);

  for (let i = 0; i < loop; i++) {
    var c = Math.sqrt(f(i));
    if (Number.isInteger(c)) {
      if (check(i, c)) {
        if (c.toString().length >= input) {
          console.log(i + " " + (i + 1) + " " + c);
          break;
        }
      }
    }
  }
}

// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"))
0