結果

問題 No.16 累乗の加算
ユーザー 826814741_6826814741_6
提出日時 2018-12-26 16:23:37
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 325 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 6,692 KB
実行使用メモリ 6,952 KB
最終ジャッジ日時 2024-04-09 02:54:40
合計ジャッジ時間 916 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,944 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
6,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

print((function (g, fh, m)
	local f,r = g(fh:read("*n"),m),0
	for _=1,fh:read("*n") do r=r+f(fh:read("*n"))%m end
	return r%m
end)(function (x, m)
	local ba,rs = bit.band,bit.rshift
	return function (n)
		local r=1
		while n~=0 do r,x,n=ba(n,1)~=0 and r*(x%m) or r,x*(x%m),rs(n,1) end
		return r
	end
end, io.stdin, 1000003))
0