結果

問題 No.781 円周上の格子点の数え上げ
ユーザー 👑 obakyanobakyan
提出日時 2019-04-20 17:26:01
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 273 ms / 2,000 ms
コード長 426 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 6,948 KB
実行使用メモリ 133,736 KB
最終ジャッジ日時 2024-04-09 03:21:33
合計ジャッジ時間 6,786 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 257 ms
133,604 KB
testcase_01 AC 258 ms
133,660 KB
testcase_02 AC 258 ms
133,716 KB
testcase_03 AC 258 ms
133,568 KB
testcase_04 AC 256 ms
133,728 KB
testcase_05 AC 256 ms
133,652 KB
testcase_06 AC 258 ms
133,652 KB
testcase_07 AC 255 ms
133,660 KB
testcase_08 AC 261 ms
133,688 KB
testcase_09 AC 258 ms
133,600 KB
testcase_10 AC 254 ms
133,672 KB
testcase_11 AC 254 ms
133,564 KB
testcase_12 AC 265 ms
133,732 KB
testcase_13 AC 273 ms
133,728 KB
testcase_14 AC 256 ms
133,628 KB
testcase_15 AC 255 ms
133,736 KB
testcase_16 AC 253 ms
133,628 KB
testcase_17 AC 266 ms
133,652 KB
testcase_18 AC 253 ms
133,636 KB
testcase_19 AC 254 ms
133,664 KB
testcase_20 AC 253 ms
133,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local max = 10000000
local t = {}
for i = 1, max do t[i] = 0 end
local a, b, a2, b2
for a = 0, 3162 do
  a2 = a * a
  b = a
  b2 = b * b
  if(a == 0) then
    b, b2 = 1, 1
  end
  while(a2 + b2 <= max) do
    t[a2 + b2] = t[a2 + b2] + ((a2 == b2 or a == 0) and 4 or 8)
    b = b + 1
    b2 = b * b
  end
end
local mma = math.max
local mx = 0
local x, y = io.read("*n", "*n")
for i = x, y do
  mx = mma(t[i], mx)
end
print(mx)
0