結果
| 問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-06-07 17:13:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 950 bytes |
| コンパイル時間 | 885 ms |
| コンパイル使用メモリ | 64,964 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-15 00:32:11 |
| 合計ジャッジ時間 | 1,789 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 WA * 2 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <sstream>
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef vector<int> VI;
const ll M = 1e10;
int main(void){
int n;
cin >> n;
ll s0 = 0, s1 = 0;
REP(i, 0, n) {
string line;
ll q;
cin >> line;
stringstream ls;
ls << line;
ls >> q;
char o = ls.get();
ll r = 0;
if (o == '.') {
string s;
ls >> s;
while (s.length() < 10) {
s += '0';
}
stringstream ss;
ss << s;
ss >> r;
}
if (line[0] == '-') {
r = -r;
}
s0 += q;
s1 += r;
}
ll q = s1 / M;
s0 += q;
s1 -= q * M;
int sgn = s0 < 0;
if (sgn) {
s0 = -s0;
s1 = -s1;
}
if (s0 > 0 && s1 < 0) {
s0--;
s1 += M;
}
s1 = abs(s1);
if (sgn) {
printf("-");
}
printf("%lld.%010lld\n", s0, s1);
}