結果
問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
ユーザー |
|
提出日時 | 2018-08-24 17:04:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,428 bytes |
コンパイル時間 | 710 ms |
コンパイル使用メモリ | 81,316 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-22 19:04:21 |
合計ジャッジ時間 | 1,536 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 12 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<string> #include<iomanip> using namespace std; typedef long long ll; const ll INF = 1e10; vector<string> split(string str, char del){ vector<string> ret; string cutoff = ""; for(int i = 0; i < str.length(); i++){ if(str[i] == del){ if(cutoff != "") ret.push_back(cutoff); cutoff = ""; }else{ cutoff += str[i]; } } if(cutoff != "") ret.push_back(cutoff); return ret; } int main(){ int n; cin >> n; ll integer = 0, decimal = 0; for(int i = 0; i < n; i++){ string line; cin >> line; if(count(line.begin(), line.end(), '.')){ vector<string> v = split(line, '.'); integer += stoll(v[0]); while(v[1].size() != 10) v[1] += "0"; decimal += stoll(v[1]) * (v[0][0] == '-' ? -1 : 1); }else{ integer += stoll(line); } } if(abs(decimal) >= INF){ integer += decimal/INF; decimal %= INF; } bool minus = false; if(decimal < 0){ if(integer != 0){ integer--; decimal += INF; }else{ minus = true; decimal = abs(decimal); } } if(minus) cout << "-"; cout << integer << "." << right << setw(10) << setfill('0') << decimal << endl; return 0; }