結果
問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
ユーザー |
|
提出日時 | 2018-08-16 20:41:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,045 bytes |
コンパイル時間 | 692 ms |
コンパイル使用メモリ | 67,908 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-04 11:10:34 |
合計ジャッジ時間 | 2,030 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 WA * 4 RE * 5 |
ソースコード
#include<iostream> #include<string> using namespace std; typedef long long ll; int main(){ int n; ll accum = 0; cin >> n; string a; for(int i = 0; i < n; i++){ cin >> a; int dotpos; for(dotpos = 0; dotpos < a.length(); dotpos++) if(a[dotpos] == '.') break; ll val; if(dotpos == a.length()){ val = stoll(a) * 10000000000; }else{ int residual = 10; while(dotpos != a.length()-1){ swap(a[dotpos], a[dotpos+1]); residual--; dotpos++; } val = stoll(a.substr(0, a.length()-1)); while(residual-- > 0) val *= 10; } accum += val; } bool minus = accum < 0; accum = abs(accum); string decimal = ""; for(int i = 0; i < 10; i++){ int digit = accum % 10; decimal = (char)('0' + digit) + decimal; accum /= 10; } cout << (minus ? "-" : "") << accum << "." << decimal << endl; return 0; }