結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー le_panda_noirle_panda_noir
提出日時 2020-06-13 17:23:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 849 bytes
コンパイル時間 992 ms
コンパイル使用メモリ 72,596 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-07 21:57:07
合計ジャッジ時間 3,685 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
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;

  long long ans = 0;
  rep(i, N) {
    string s; cin >> s;
    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);
    }
    ans += stoll(s);
  }

  string s = to_string(ans);
  if (s.size() == 10)
    cout << "0." << s << endl;
  else if (s[0] == '-' && s.size() == 11)
    cout << "-0." << s.substr(1) << endl;
  else
    cout << s.substr(0, s.size()-10) << "." << s.substr(s.size()-10) << endl;

  return 0;
}
0