結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー むらためむらため
提出日時 2019-01-24 18:36:33
言語 Nim
(2.0.2)
結果
RE  
実行時間 -
コード長 1,193 bytes
コンパイル時間 2,523 ms
コンパイル使用メモリ 70,336 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 02:43:13
合計ジャッジ時間 3,658 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 RE -
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 RE -
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,math,strutils

proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    let k = getchar_unlocked()
    if k < '0': break
    result = 10 * result + k.ord - '0'.ord

proc scanFixed(): tuple[a,b:int64] =
  var minus = false
  var now = 0
  var isA = true
  var bcnt = 10_0000_00000
  while true:
    let k = getchar_unlocked()
    if k == '-' : minus = true
    elif k == '.':
      if minus : now *= -1
      result.a = now
      now = 0
      isA = false
    elif k < '0':
      if minus : now *= -1
      if isA : result.a = now
      else: result.b = now * bcnt
      return
    else:
      now = 10 * now + k.ord - '0'.ord
      if not isA: bcnt = bcnt div 10


let n = scan()
let F = newSeqWith(n,scanFixed())
let aSum = F.mapIt(it.a).sum()
var bSum = F.mapIt(it.b).sum()
var a = aSum + bSum div 10_0000_00000
var b = bSum mod 10_0000_00000
# echo a
# echo b
if (a < 0) xor (b < 0) :
  var minus = a <= 0
  if minus :
    stdout.write "-"
    a *= -1
    b *= -1
  if b mod 10_0000_00000 != 0:
    a -= 1
    b += 10_0000_00000
# echo a
# echo b

let B = "0".repeat(10 - ($(b.abs)).len) & ($b.abs)
echo a,".",B
0