結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー 👑 obakyanobakyan
提出日時 2021-01-22 21:40:21
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 1,212 ms / 2,000 ms
コード長 1,167 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 5,296 KB
実行使用メモリ 10,540 KB
最終ジャッジ日時 2023-08-27 18:14:20
合計ジャッジ時間 63,429 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 607 ms
6,348 KB
testcase_04 AC 602 ms
6,372 KB
testcase_05 AC 532 ms
6,316 KB
testcase_06 AC 530 ms
6,216 KB
testcase_07 AC 820 ms
10,416 KB
testcase_08 AC 818 ms
10,308 KB
testcase_09 AC 226 ms
4,396 KB
testcase_10 AC 225 ms
4,376 KB
testcase_11 AC 1,071 ms
10,376 KB
testcase_12 AC 1,068 ms
10,424 KB
testcase_13 AC 671 ms
6,344 KB
testcase_14 AC 674 ms
6,348 KB
testcase_15 AC 594 ms
6,344 KB
testcase_16 AC 594 ms
6,316 KB
testcase_17 AC 1,140 ms
10,364 KB
testcase_18 AC 1,134 ms
10,392 KB
testcase_19 AC 988 ms
10,344 KB
testcase_20 AC 983 ms
10,376 KB
testcase_21 AC 1,056 ms
10,336 KB
testcase_22 AC 1,060 ms
10,328 KB
testcase_23 AC 709 ms
6,384 KB
testcase_24 AC 709 ms
6,348 KB
testcase_25 AC 107 ms
4,380 KB
testcase_26 AC 108 ms
4,384 KB
testcase_27 AC 367 ms
4,380 KB
testcase_28 AC 367 ms
4,376 KB
testcase_29 AC 458 ms
6,272 KB
testcase_30 AC 453 ms
6,476 KB
testcase_31 AC 606 ms
6,360 KB
testcase_32 AC 604 ms
6,308 KB
testcase_33 AC 447 ms
6,376 KB
testcase_34 AC 447 ms
6,336 KB
testcase_35 AC 593 ms
6,312 KB
testcase_36 AC 596 ms
6,432 KB
testcase_37 AC 115 ms
4,380 KB
testcase_38 AC 115 ms
4,376 KB
testcase_39 AC 94 ms
4,376 KB
testcase_40 AC 94 ms
4,500 KB
testcase_41 AC 207 ms
4,396 KB
testcase_42 AC 207 ms
4,380 KB
testcase_43 AC 162 ms
4,376 KB
testcase_44 AC 1,131 ms
10,416 KB
testcase_45 AC 469 ms
6,344 KB
testcase_46 AC 154 ms
4,380 KB
testcase_47 AC 801 ms
10,468 KB
testcase_48 AC 737 ms
6,368 KB
testcase_49 AC 742 ms
10,540 KB
testcase_50 AC 571 ms
6,376 KB
testcase_51 AC 27 ms
4,376 KB
testcase_52 AC 1,009 ms
10,392 KB
testcase_53 AC 1,130 ms
10,448 KB
testcase_54 AC 1,196 ms
10,452 KB
testcase_55 AC 1,174 ms
10,336 KB
testcase_56 AC 1,201 ms
10,312 KB
testcase_57 AC 1,200 ms
10,352 KB
testcase_58 AC 1,192 ms
10,388 KB
testcase_59 AC 1,187 ms
10,424 KB
testcase_60 AC 1,163 ms
10,380 KB
testcase_61 AC 1,096 ms
10,320 KB
testcase_62 AC 1,194 ms
10,436 KB
testcase_63 AC 1,190 ms
10,484 KB
testcase_64 AC 1,202 ms
10,332 KB
testcase_65 AC 1,186 ms
10,320 KB
testcase_66 AC 1,188 ms
10,312 KB
testcase_67 AC 1,212 ms
10,436 KB
testcase_68 AC 1,164 ms
10,412 KB
testcase_69 AC 1,077 ms
10,376 KB
testcase_70 AC 1,087 ms
10,388 KB
testcase_71 AC 1,040 ms
10,420 KB
testcase_72 AC 1,205 ms
10,368 KB
testcase_73 AC 1,084 ms
10,368 KB
testcase_74 AC 1,070 ms
10,312 KB
testcase_75 AC 1,084 ms
10,416 KB
testcase_76 AC 1,068 ms
10,368 KB
testcase_77 AC 1,088 ms
10,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mmi, mma = math.min, math.max
local mfl, mce = math.floor, math.ceil
local n, k, mod = io.read("*n", "*n", "*n")
local t = {}
for i = 1, 4 do
  t[i] = {}
  for j = 1, n do
    t[i][j] = io.read("*n")
  end
  table.sort(t[i])
end

local function bmul(x, y)
  local x1, y1 = x % 10000, y % 10000
  local x2, y2 = mfl(x / 10000) % 10000, mfl(y / 10000) % 10000
  local x3, y3 = mfl(x / 100000000), mfl(y / 100000000)
  local ret = (x1 * y1 + (x1 * y2 + x2 * y1) * 10000) % mod
  ret = (ret + (x1 * y3 + x2 * y2 + x3 * y1) * 10000 % mod * 10000 % mod) % mod
  ret = (ret + (x2 * y3 + x3 * y2) * 10000 % mod * 10000 % mod * 10000) % mod
  ret = (ret +  x3 * y3 * 10000 % mod * 10000 % mod * 10000 % mod * 10000) % mod
  return ret
end

local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = mfl(pow / 2)
  end
  return res
end

local sum = 0
for i = 1, n do
  local mi = mmi(t[1][i], t[2][i], t[3][i], t[4][i])
  local ma = mma(t[1][i], t[2][i], t[3][i], t[4][i])
  local v = modpow(ma - mi, k, mod)
  sum = (sum + v) % mod
end
print(sum)
0