結果
問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
ユーザー |
![]() |
提出日時 | 2014-11-27 23:57:39 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,176 bytes |
コンパイル時間 | 953 ms |
コンパイル使用メモリ | 81,472 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-01-03 09:40:43 |
合計ジャッジ時間 | 1,783 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 WA * 18 |
ソースコード
#include <iostream> #include <vector> #include <cstdio> #include <sstream> #include <map> #include <string> #include <algorithm> #include <queue> #include <cmath> using namespace std; void func(long long &a, long long &b, string s){ } int main(){ int n; cin >> n; long long a = 0; long long b = 0; for(int i=0; i<n; i++){ string s; cin >> s; long long sgn = 1; if(s[0] == '-'){ s = s.substr(1); sgn = -1; } //cerr << s << endl; auto pos = s.find('.'); { string sub = s.substr(0, pos); //cerr << sub << endl; stringstream ss; ss << sub; long long x; ss >> x; a += sgn * x; } if(pos != string::npos){ string sub = s.substr(pos+1); for(int i=0; i<10; i++){ sub += '0'; } //cerr << sub.substr(0,10) << endl; stringstream ss; ss << sub.substr(0,10); long long x; ss >> x; b += sgn * x; } a += b/10000000000LL; b %= 10000000000LL; } stringstream ss; ss << b; string bs; ss >> bs; for(int i=0; i<10; i++){ bs += '0'; } cout << a << '.' << bs.substr(0,10) << endl; return 0; }