結果
| 問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-11-27 23:46:58 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 984 bytes |
| コンパイル時間 | 830 ms |
| コンパイル使用メモリ | 58,968 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-15 00:28:07 |
| 合計ジャッジ時間 | 2,039 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 WA * 3 |
ソースコード
#include <iostream>
#include <sstream>
using namespace std;
typedef long long ll;
const ll B = 1e10;
int main(){
int N;
cin >> N;
ll inte = 0, frac = 0;
for(int i=0;i<N;i++){
string s, is, fs;
cin >> s;
int p = (int)s.find(".");
if(p != -1){
is = s.substr(0, p);
fs = s.substr(p + 1);
} else {
is = s;
}
fs = fs + string(10 - fs.size(), '0');
ll in = atoll(is.c_str());
ll fr = atoll(fs.c_str());
if(is[0] == '-')fr = -fr;
inte += in;
frac += fr;
}
while(frac < 0){
--inte;
frac += B;
}
while(frac >= B){
++inte;
frac -= B;
}
if(inte < 0 && frac > 0){
++inte;
frac = B - frac;
}
printf("%lld.%010lld\n", inte, frac);
return 0;
}