結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー le_panda_noirle_panda_noir
提出日時 2020-06-13 17:38:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,232 bytes
コンパイル時間 7,360 ms
コンパイル使用メモリ 378,156 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-07 22:17:01
合計ジャッジ時間 8,940 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 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,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 WA -
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 #

#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using ll = mp::cpp_int;
using namespace std;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

int main() {
  int N; cin >> N;

  ll ans = 0;
  rep(i, N) {
    string s; cin >> s;
    bool negative = s[0] == '-';
    if (negative) s = s.substr(1);
    auto pos = s.find(".");

    if (s == "0") continue;
    if (pos == string::npos)
      s += "0000000000";
    else {
      int len = s.size() - 1 - pos;
      rep(j, 10-len)
        s += "0";
      s = (s.substr(0, pos) == "0" ? "" : s.substr(0, pos)) + s.substr(pos+1);
    }
    while (s[0] == '0') s = s.substr(1);
    if (negative) s = '-' + s;
    ans += ll(s);
  }

  bool negative = ans < 0;
  if (negative) ans *= -1;
  string s = ans.str();
  if (ans == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (negative) cout << "-";
  if (s.size() <= 10) {
    string zero = "";
    rep(i, 10-(s.size()-(s[0] == '-')))
      zero += '0';
    cout << "0." << zero << s << endl;
  } else
    cout << s.substr(0, s.size()-10) << "." << s.substr(s.size()-10) << endl;

  return 0;
}
0