結果
| 問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
le_panda_noir
|
| 提出日時 | 2020-06-13 17:38:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,232 bytes |
| コンパイル時間 | 6,317 ms |
| コンパイル使用メモリ | 338,708 KB |
| 最終ジャッジ日時 | 2025-01-11 03:50:23 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 29 WA * 1 |
ソースコード
#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;
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)
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);
}
while (s[0] == '0') s = s.substr(1);
if (negative) s = '-' + s;
ans += ll(s);
}
bool negative = ans < 0;
if (negative) ans *= -1;
string s = ans.str();
if (ans == 0) {
cout << 0 << endl;
return 0;
}
if (negative) cout << "-";
if (s.size() <= 10) {
string zero = "";
rep(i, 10-(s.size()-(s[0] == '-')))
zero += '0';
cout << "0." << zero << s << endl;
} else
cout << s.substr(0, s.size()-10) << "." << s.substr(s.size()-10) << endl;
return 0;
}
le_panda_noir