結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー diginatu
提出日時 2014-11-28 01:26:21
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 743 bytes
コンパイル時間 1,949 ms
コンパイル使用メモリ 148,488 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-12 01:41:35
合計ジャッジ時間 2,945 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

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