結果
| 問題 | No.500 階乗電卓 |
| コンテスト | |
| ユーザー |
nobigomu
|
| 提出日時 | 2018-05-15 18:46:01 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 673 bytes |
| 記録 | |
| コンパイル時間 | 314 ms |
| コンパイル使用メモリ | 7,068 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-28 12:09:51 |
| 合計ジャッジ時間 | 1,046 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
local ffi = require 'ffi'
local M = ffi.load 'ssl'
ffi.cdef [[
typedef struct bignum_st {
uint64_t *d;
int top;
int dmax;
int neg;
int flags;
} BN;
typedef BN * BN_ptr;
typedef const BN * BN_srcptr;
BN_ptr BN_new(void);
void BN_free(BN_ptr);
int BN_set_word(BN_ptr, uint64_t);
int BN_mul_word(BN_ptr, uint64_t);
char * BN_bn2dec(BN_srcptr);
void CRYPTO_free(void *, const char *, int);
]]
print((function (n)
if n>=50 then return "000000000000" end
local b=ffi.gc(M.BN_new(),M.BN_free)
M.BN_set_word(b,1)
for i=2,n do M.BN_mul_word(b,i+0ULL) end
return ffi.string(ffi.gc(M.BN_bn2dec(b),function (a) M.CRYPTO_free(a,"",0) end)):sub(-12)
end)(io.stdin:read("*n")))
nobigomu