結果

問題 No.500 階乗電卓
ユーザー 826814741_6826814741_6
提出日時 2019-02-10 02:00:30
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 672 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 5,212 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 04:12:01
合計ジャッジ時間 1,212 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

local F = require 'ffi'
local M = F.load 'ssl'
F.cdef [[
typedef struct bignum_st { uint64_t *d; int top; int dmax; int neg; int flag; } BN;
BN * BN_new(void);
void BN_free(BN *);
int BN_set_word(BN *, uint64_t);
int BN_mul_word(BN *, uint64_t);
char * BN_bn2dec(const BN *);
void CRYPTO_free(void *, const char *, int);
]]

print((function (f, g, n)
	if n>=50 then return "000000000000" end
	return f(g(n)):sub(-12)
end)(function (bn)
	return F.string(F.gc(M.BN_bn2dec(bn), function (a) M.CRYPTO_free(a,"",0) end))
end, function (n)
	local bn = F.gc(M.BN_new(), M.BN_free)
	M.BN_set_word(bn, 1)
	for i=2,n do M.BN_mul_word(bn, i) end
	return bn
end, io.stdin:read("*n")))
0