結果
問題 | No.428 小数から逃げる夢 |
ユーザー |
![]() |
提出日時 | 2018-06-06 23:27:05 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,006 bytes |
コンパイル時間 | 30 ms |
コンパイル使用メモリ | 6,688 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-30 10:24:27 |
合計ジャッジ時間 | 2,278 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 100 |
ソースコード
local ffi = require 'ffi'local M = ffi.load 'gmp'ffi.cdef [[typedef unsigned long mp_limb_t;typedef struct {int _mp_alloc;int _mp_size;mp_limb_t * _mp_d;} __mpz_struct;typedef __mpz_struct mpz_t[1];typedef const __mpz_struct * mpz_srcptr;typedef __mpz_struct * mpz_ptr;void __gmpz_init_set_d(mpz_ptr, double);int __gmpz_init_set_str(mpz_ptr, const char *, int);char * __gmpz_get_str(char *, int, mpz_ptr);void __gmpz_mul(mpz_ptr, mpz_srcptr, mpz_srcptr);]]local ct, gt = ffi.typeof 'char[?]', ffi.typeof 'mpz_t'local D='1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991'print((function (N)local d,n,t=gt(),gt(),ct(#D+3)M.__gmpz_init_set_str(d,D,10)M.__gmpz_init_set_d(n,N)M.__gmpz_mul(n,d,n)M.__gmpz_get_str(t,10,n)local r=ffi.string(t)return #r==#D and "0."..r or r:sub(1,#r-#D).."."..r:sub(#r-#D+1)end)(io.stdin:read("*n")))