結果
問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
ユーザー |
|
提出日時 | 2022-11-28 23:02:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 741 bytes |
コンパイル時間 | 1,441 ms |
コンパイル使用メモリ | 170,168 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-06 00:38:37 |
合計ジャッジ時間 | 2,990 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 WA * 8 RE * 6 |
ソースコード
// 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; }