結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー Aimee PetrescuAimee Petrescu
提出日時 2022-11-28 23:02:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 741 bytes
コンパイル時間 1,470 ms
コンパイル使用メモリ 165,120 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 20:20:50
合計ジャッジ時間 3,080 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

// unsolved
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  ll ans1 = 0, ans2 = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    ll d = 1;
    if (s[0] == '-') d = -1;
    int pos = s.rfind('.');
    if (pos == -1) {
      ans1 += stoi(s);
    } else {
      for (int j = 0; j < pos; j++) {
        if (j == 0 && d == -1) continue;
        ans1 += (s[j] - '0') * pow(10, pos - j - 1) * d;
      }
      for (int j = pos + 1; j < s.size(); j++) {
        ans2 += (s[j] - '0') * pow(10, 9 - (j - pos) + 1) * d;
      }
    }
  }
  cout << ans1 + ans2 / ll(1e10) << ".";
  cout << setfill('0') << left << setw(10) << abs(ans2) % ll(1e10) << endl;
}
0