結果

問題 No.800 四平方定理
ユーザー yudedakoyudedako
提出日時 2022-01-26 20:51:07
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 1,230 ms / 2,000 ms
コード長 416 bytes
コンパイル時間 11,200 ms
コンパイル使用メモリ 257,792 KB
実行使用メモリ 93,996 KB
最終ジャッジ日時 2023-08-25 03:12:17
合計ジャッジ時間 48,853 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 947 ms
62,232 KB
testcase_01 AC 962 ms
62,076 KB
testcase_02 AC 963 ms
62,416 KB
testcase_03 AC 972 ms
62,084 KB
testcase_04 AC 954 ms
62,416 KB
testcase_05 AC 969 ms
62,348 KB
testcase_06 AC 971 ms
62,560 KB
testcase_07 AC 964 ms
61,924 KB
testcase_08 AC 961 ms
62,468 KB
testcase_09 AC 962 ms
62,548 KB
testcase_10 AC 1,058 ms
77,116 KB
testcase_11 AC 1,075 ms
78,984 KB
testcase_12 AC 1,078 ms
79,240 KB
testcase_13 AC 1,075 ms
78,980 KB
testcase_14 AC 1,083 ms
79,332 KB
testcase_15 AC 1,066 ms
79,020 KB
testcase_16 AC 1,065 ms
79,328 KB
testcase_17 AC 1,084 ms
78,844 KB
testcase_18 AC 1,048 ms
79,120 KB
testcase_19 AC 1,056 ms
79,608 KB
testcase_20 AC 921 ms
62,204 KB
testcase_21 AC 931 ms
62,180 KB
testcase_22 AC 1,063 ms
79,328 KB
testcase_23 AC 1,195 ms
93,996 KB
testcase_24 AC 1,208 ms
93,656 KB
testcase_25 AC 1,203 ms
93,464 KB
testcase_26 AC 932 ms
62,272 KB
testcase_27 AC 943 ms
64,112 KB
testcase_28 AC 1,183 ms
93,488 KB
testcase_29 AC 1,188 ms
93,864 KB
testcase_30 AC 1,230 ms
93,756 KB
testcase_31 AC 1,171 ms
91,752 KB
testcase_32 AC 1,186 ms
93,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import scala.annotation.tailrec
import scala.io.StdIn.*
import scala.math.*

@main def main =
  val Array(n, d) = readLine().split(' ').map(_.toInt)
  val factorCount = Array.fill(max(n * n * 2, d) + 1){0}

  for
    w <- 1 to n
    z <- 1 to w
  do
    factorCount(w * w - z * z) += 1

  var result = 0L
  for
    x <- 1 to n
    y <- 1 to n
  do
    result += factorCount(abs(d - x * x - y * y))

  println(result)
0