結果

問題 No.81 すべて足すだけの簡単なお仕事です。
コンテスト
ユーザー diginatu
提出日時 2014-11-28 01:26:21
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
WA  
実行時間 -
コード長 743 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,619 ms
コンパイル使用メモリ 129,440 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2026-03-05 05:49:53
合計ジャッジ時間 2,570 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import std.stdio, std.conv, std.math, std.string, std.range, std.array,
       std.algorithm;

void main(){
  auto N = readln().strip().to!int();
  long ansi, ansd;
  foreach(immutable int i; 0 .. N) {
    auto t = readln().strip().split('.').map!(to!string)();
    bool minus = false;
    if(t[0][0] == '-') minus = true;
    ansi += t[0].to!long;
    char[] td = "0000000000".dup();
    foreach(ulong j; 0 .. t[1].length) {
      td[j] = t[1][j];
    }
    if(t.length == 2) {
      if(minus) ansd -= td.to!long;
      else ansd += td.to!long;
    }

    //writeln(ansi, ", ", ansd);

    long tt = ansd/(10L^^10);
    ansi += tt;
    ansd -= tt*(10L^^10);
  }

  write(ansi, ".");
  writefln("%010d", ansd);
}
0