結果
問題 | 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, truelocal all480 = truelocal alleven = truelocal all50 = truelocal allmod7same = truelocal sum = 0local first = tonumber(str:sub(1, 1))local n = #strlocal t = {}local min = 9local mmi, mfl = math.min, math.floorfor i = 1, n dolocal a = tonumber(str:sub(i, i))t[i] = aif a ~= 0 then min = mmi(min, a) endif a ~= first then allsame = false endendfor i = 1, n doif t[i] % min ~= 0 thenallsame2 = falsebreakendendlocal ret = 1if allsame2 thenret = minfor i = 1, n dot[i] = mfl(t[i] / min)endendfor i = 1, n dolocal a = t[i]if a % 7 ~= first % 7 thenallmod7same = falseendsum = sum + aendif allsame thenprint(str)elseif sum % 9 == 0 thenret = ret * 9elseif sum % 3 == 0 thenret = ret * 3endif allmod7same and (n % 6 == 0) thenret = ret * 7endprint(ret)end