結果
問題 | No.167 N^M mod 10 |
ユーザー | nobigomu |
提出日時 | 2018-05-29 00:34:22 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
AC
|
実行時間 | 12 ms / 1,000 ms |
コード長 | 1,398 bytes |
コンパイル時間 | 123 ms |
コンパイル使用メモリ | 5,148 KB |
実行使用メモリ | 4,472 KB |
最終ジャッジ日時 | 2023-10-22 00:20:58 |
合計ジャッジ時間 | 1,589 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 3 ms
4,452 KB |
testcase_02 | AC | 11 ms
4,472 KB |
testcase_03 | AC | 11 ms
4,472 KB |
testcase_04 | AC | 12 ms
4,472 KB |
testcase_05 | AC | 3 ms
4,452 KB |
testcase_06 | AC | 2 ms
4,452 KB |
testcase_07 | AC | 2 ms
4,452 KB |
testcase_08 | AC | 2 ms
4,452 KB |
testcase_09 | AC | 2 ms
4,452 KB |
testcase_10 | AC | 2 ms
4,452 KB |
testcase_11 | AC | 2 ms
4,452 KB |
testcase_12 | AC | 3 ms
4,452 KB |
testcase_13 | AC | 3 ms
4,452 KB |
testcase_14 | AC | 3 ms
4,448 KB |
testcase_15 | AC | 3 ms
4,452 KB |
testcase_16 | AC | 2 ms
4,452 KB |
testcase_17 | AC | 2 ms
4,452 KB |
testcase_18 | AC | 2 ms
4,452 KB |
testcase_19 | AC | 2 ms
4,452 KB |
testcase_20 | AC | 2 ms
4,452 KB |
testcase_21 | AC | 2 ms
4,452 KB |
testcase_22 | AC | 8 ms
4,468 KB |
testcase_23 | AC | 8 ms
4,468 KB |
testcase_24 | AC | 7 ms
4,468 KB |
testcase_25 | AC | 8 ms
4,468 KB |
testcase_26 | AC | 2 ms
4,456 KB |
testcase_27 | AC | 10 ms
4,468 KB |
testcase_28 | AC | 3 ms
4,420 KB |
ソースコード
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_dec2bn(BN_ptr *, const char *); char * BN_bn2dec(BN_srcptr); void CRYPTO_free(void *, const char *, int); typedef struct bignum_pool_item { BN vals[16]; struct bignum_pool_item *prev, *next; } BN_POOL_ITEM; typedef struct bignum_pool { BN_POOL_ITEM *head, *current, *tail; unsigned used, size; } BN_POOL; typedef struct bignum_ctx_stack { unsigned int *indexes; unsigned int depth, size; } BN_STACK; typedef struct bignum_ctx { BN_POOL pool; BN_STACK stack; unsigned int used; int err_stack; int too_many; int flags; } BN_CTX; typedef BN_CTX * BN_CTX_ptr; BN_CTX_ptr BN_CTX_new(void); void BN_CTX_free(BN_CTX_ptr); int BN_mod_exp(BN_ptr, BN_srcptr, BN_srcptr, BN_srcptr, BN_CTX_ptr); ]] local ct = ffi.typeof 'BN_ptr[1]' print((function (n, m) local r,mod,ctx=ffi.gc(M.BN_new(),M.BN_free),ffi.gc(M.BN_new(),M.BN_free),ffi.gc(M.BN_CTX_new(),M.BN_CTX_free) M.BN_dec2bn(n,io.stdin:read("*l")) M.BN_dec2bn(m,io.stdin:read("*l")) M.BN_set_word(mod,10ULL) M.BN_mod_exp(r, n[0], m[0], mod, ctx) return ffi.string(ffi.gc(M.BN_bn2dec(r),function (a) M.CRYPTO_free(a,"",0) end)) end)(ct(), ct()))