結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー むらためむらため
提出日時 2019-01-24 18:38:58
言語 Nim
(2.0.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,218 bytes
コンパイル時間 5,855 ms
コンパイル使用メモリ 70,256 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 22:47:30
合計ジャッジ時間 6,109 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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
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
  if ($(b.abs)).len >= 11:
    a += 1
    b -= 10_0000_00000

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