結果
| 問題 |
No.443 GCD of Permutation
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2019-06-03 22:27:11 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 924 bytes |
| コンパイル時間 | 52 ms |
| コンパイル使用メモリ | 5,248 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 00:08:54 |
| 合計ジャッジ時間 | 969 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 28 |
ソースコード
local str = io.read()
local allsame, allsame2 = true, true
local all480 = true
local alleven = true
local all50 = true
local allmod7same = true
local sum = 0
local first = tonumber(str:sub(1, 1))
local n = #str
local t = {}
local min = 9
local mmi, mfl = math.min, math.floor
for i = 1, n do
local a = tonumber(str:sub(i, i))
t[i] = a
if a ~= 0 then min = mmi(min, a) end
if a ~= first then allsame = false end
end
for i = 1, n do
if t[i] % min ~= 0 then
allsame2 = false
break
end
end
local ret = 1
if allsame2 then
ret = min
for i = 1, n do
t[i] = mfl(t[i] / min)
end
end
for i = 1, n do
local a = t[i]
if a % 7 ~= first % 7 then
allmod7same = false
end
sum = sum + a
end
if allsame then
print(str)
else
if sum % 9 == 0 then
ret = ret * 9
elseif sum % 3 == 0 then
ret = ret * 3
end
if allmod7same and (n % 6 == 0) then
ret = ret * 7
end
print(ret)
end