結果
問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
ユーザー |
![]() |
提出日時 | 2016-09-29 15:52:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,067 bytes |
コンパイル時間 | 626 ms |
コンパイル使用メモリ | 64,896 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-21 10:32:55 |
合計ジャッジ時間 | 3,545 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 8 WA * 2 RE * 20 |
ソースコード
#include<iostream> #include<string> #include<math.h> #include<algorithm> using namespace std; int main(){ string s; string si; string sd; string ss=""; int n; int keta; int kuriagari; long long int in = 0; long long int de = 0; long long int toi = 0; long long int tod = 0; int index; cin >> n; for (int i = 0; i < n; i++){ cin >> s; index = (int)s.find("."); if (index == -1){ in = stoi(s); de = 0; } else{ si = s.substr(0, index); sd = s.substr(index + 1, s.length() - index); for (int is = 10 - sd.length(); is>0; is--){ sd += "0"; } in = stoi(si); de = stoi(sd); } toi += in; tod += de; } if (tod > 0){ keta = 10 - ((int)log10(tod) + 1); } else{ keta = 9; } if (keta<0){ kuriagari = tod / 10000000000; toi += kuriagari; tod -= kuriagari * 10000000000; if (tod > 0){ keta = 10 - ((int)log10(tod) + 1); } else{ keta = 9; } } //cout << keta << endl; while (keta > 0){ ss += "0"; keta--; } //cout << ss << endl; cout << toi << "." << ss << tod << endl; return 0; }