結果

問題 No.906 Y字グラフ
ユーザー 👑 obakyanobakyan
提出日時 2020-04-18 11:41:52
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 7,072 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 20:39:49
合計ジャッジ時間 1,484 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 1 ms
6,944 KB
testcase_27 AC 1 ms
6,944 KB
testcase_28 AC 1 ms
6,940 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 AC 1 ms
6,940 KB
testcase_31 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mod = 1000000007LL
local function badd(x, y) return (x + y) % mod end
local function bmul(x, y) return (x * y) % mod end
local function bsub(x, y)
  return x < y and x - y + mod or x - y
end
local function lltonumber(str)
  local ret = 0LL
  for i = 1, #str do
    ret = ret * 10LL + str:sub(i, i):byte() - 48
  end
  return ret
end
local sn = io.read()
local n = lltonumber(sn)
n = n - 4LL
local allsame = n % 3LL == 0LL and 1LL or 0LL
local onediff = 1LL + (n / 2LL)
if n % 3LL == 0LL then
  onediff = onediff - 1LL
end
local alldiff = bmul(500000004LL, bmul((n + 2LL) % mod, (n + 1LL) % mod))
alldiff = bsub(alldiff, allsame)
alldiff = bsub(alldiff, bmul(3LL, onediff))
alldiff = bmul(166666668LL, alldiff) -- 1/6
local ret = (allsame + onediff + alldiff) % mod
local retstr = tostring(ret):gsub("LL", "")
print(retstr)
0