結果

問題 No.428 小数から逃げる夢
ユーザー nobigomu
提出日時 2018-06-06 23:28:03
言語 Lua
(LuaJit 2.1.1734355927)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 1,556 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 5,504 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-30 10:24:21
合計ジャッジ時間 2,897 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

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_clear_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_mul(BN_ptr, BN_srcptr, BN_srcptr, BN_CTX_ptr);
]]
local D = '1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
    757677787980818283848586878889909192939495969798991'
print((function (ctx, N)
local d,n=ffi.new("BN_ptr[1]"),ffi.gc(M.BN_new(),M.BN_clear_free)
M.BN_dec2bn(d,D)
M.BN_set_word(n,N)
M.BN_mul(n,d[0],n,ctx)
local r=ffi.string(ffi.gc(M.BN_bn2dec(n),function (a) M.CRYPTO_free(a,"",0) end))
return #r==#D and "0."..r or r:sub(1,#r-#D).."."..r:sub(#r-#D+1)
end)(ffi.gc(M.BN_CTX_new(),M.BN_CTX_free), io.stdin:read("*n")+0ULL))
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0