結果

問題 No.432 占い(Easy)
ユーザー nobigomunobigomu
提出日時 2018-05-04 12:51:51
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 490 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-10 09:33:34
合計ジャッジ時間 1,634 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

local ffi = require 'ffi'
local C = ffi.C
ffi.cdef 'int scanf(const char *, ...);'

do 
local cd,a=ffi.new("int8_t[1]"),{}
for _=1,io.stdin:read("*n") do
	C.scanf(" %c",cd) a[1]=cd[0]-48
	for i=2,1000 do
		C.scanf("%c",cd) if cd[0]==10 then break end a[i]=cd[0]-48
		a[i-1]=a[i-1]+a[i]>9 and a[i-1]+a[i]-9 or a[i-1]+a[i]
	end if #a>1 then a[#a]=nil end
	while #a>1 do
		for i=2,#a do
			a[i-1]=a[i-1]+a[i]>9 and a[i-1]+a[i]-9 or a[i-1]+a[i]
		end a[#a]=nil
	end
	io.write(a[1],"\n")
end
end
0