結果

問題 No.443 GCD of Permutation
ユーザー 👑 obakyanobakyan
提出日時 2019-06-03 21:47:53
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 708 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 5,152 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 23:29:29
合計ジャッジ時間 1,829 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

local str = io.read()
local allsame = true
local all480 = true
local alleven = true
local all50 = true
local sum = 0
local first = tonumber(str:sub(1, 1))
local n = #str
for i = 1, n do
  local a = tonumber(str:sub(i, i))
  if a ~= first then
    allsame = false
  end
  if a % 4 ~= 0 then
    all480 = false
  end
  if a % 2 ~= 0 then
    alleven = false
  end
  if a % 5 ~= 0 then
    all50 = false
  end
  sum = sum + a
end

if allsame then
  print(str)
else
  local ret = 1
  if all480 then
    ret = ret * 4
  elseif alleven then
    ret = ret * 2
  end
  if all50 then
    ret = ret * 5
  end
  if sum % 9 == 0 then
    ret = ret * 9
  elseif sum % 3 == 0 then
    ret = ret * 3
  end
  print(ret)
end
0