結果

問題 No.25 有限小数
ユーザー むらためむらため
提出日時 2017-08-14 23:36:46
言語 Nim
(2.0.2)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 729 bytes
コンパイル時間 3,381 ms
コンパイル使用メモリ 71,996 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 14:29:25
合計ジャッジ時間 4,612 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,384 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 50) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated]
/home/judge/data/code/Main.nim(4, 51) Warning: Number of spaces around '-' is not consistent [Spacing]
/home/judge/data/code/Main.nim(1, 50) Warning: imported and not used: 'future' [UnusedImport]
/home/judge/data/code/Main.nim(1, 57) Warning: imported and not used: 'macros' [UnusedImport]
/home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'strscans' [UnusedImport]
/home/judge/data/code/Main.nim(1, 35) Warning: imported and not used: 'algorithm' [UnusedImport]
/home/judge/data/code/Main.nim(1, 45) Warning: imported and not used: 'math' [UnusedImport]

ソースコード

diff #

import sequtils,strutils,strscans,algorithm,math,future,macros,rationals
template get*():string = stdin.readLine()
proc toSeq(str:string):seq[char] = result = @[];(for s in str: result &= s)
proc split(n:int):auto = ($n).toSeq().mapIt(it.ord- '0'.ord)

proc factorize(base:var int, n:int):int =
  result = 0
  while base mod n == 0:
    result += 1
    base = base div n

let
  N = get().parseInt()
  M = get().parseInt()
var
  r = (N // M) * (1//1)
  (n,m) = (r.num,r.den)
  m2 = m.factorize(2)
  m5 = m.factorize(5)
if m != 1 : echo -1 # 2,5以外があるとダメ
elif m2 > m5 : echo 5
elif m2 == m5 : echo n.split().filterIt(it != 0)[^1] # / 1000
elif m2 < m5 : echo n.split()[^1].`*`(1 shl (m5 - m2)).split()[^1] # /1000に
0