結果
問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
ユーザー |
![]() |
提出日時 | 2020-06-13 17:58:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,295 bytes |
コンパイル時間 | 4,969 ms |
コンパイル使用メモリ | 341,812 KB |
最終ジャッジ日時 | 2025-01-11 03:51:00 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 6 |
ソースコード
#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; ll integer = 0, decimal = 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) integer += (negative ? -1 : 1) * stoll(s); else { integer += (negative ? -1 : 1) * stoll(s.substr(0, pos)); int len = s.size() - 1 - pos; rep(j, 10-len) s += "0"; s = s.substr(pos+1); while (!s.empty() && s[0] == '0') s = s.substr(1); if (!s.empty()) decimal += (negative ? -1 : 1) * stoll(s); } } integer += decimal / 10000000000LL; decimal %= 10000000000LL; if (integer >= 0 && decimal >= 0 || integer <= 0 && decimal <= 0) { cout << integer << "." << setfill('0') << setw(10) << abs(decimal) << endl; } else { if (decimal != 0) --integer; cout <<integer<<"." << setfill('0') << setw(10) << 10000000000LL-abs(decimal)<<endl; } return 0; }