結果
| 問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-15 11:03:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,767 bytes |
| コンパイル時間 | 1,825 ms |
| コンパイル使用メモリ | 170,628 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-15 01:06:36 |
| 合計ジャッジ時間 | 2,742 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 WA * 3 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x) cerr << #x << " = " << (x) << endl
using namespace std;
// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5
/* pow(x,n)はx^nを返すよ! */
template<class T>
T pow(T x, T n) {
T res = 1;
while (n > 0) {
if (n & 1) res = res * x;
x = x * x;
n >>= 1;
}
return res;
}
signed main(void) {
int i, j, k, l;
int N;
cin >> N;
ll seisuu_bubun = 0;
ll syousyuu_bubun = 0;
rep(i, N) {
string val_str;
cin >> val_str;
bool is_minus = false;
if (val_str[0] == '-') is_minus = true;
seisuu_bubun += stoll(val_str);
rep(j, val_str.size()) {
if (val_str[j] == '.') break;
}
if (j == val_str.size()) continue;
val_str = val_str.substr(j+1);
ll j_syousyuu_bubun = 0;
rep(j, val_str.size()) {
j_syousyuu_bubun += (val_str[j] - '0')*pow((ll)10, (ll)9 - j);
}
if (is_minus) j_syousyuu_bubun *= -1;
syousyuu_bubun += j_syousyuu_bubun;
}
if (syousyuu_bubun < 0) {
seisuu_bubun -= abs(syousyuu_bubun) / (ll)1e10 + 1;
syousyuu_bubun = -(abs(syousyuu_bubun) % (ll)1e10);
syousyuu_bubun += (ll)1e10;
}
seisuu_bubun += syousyuu_bubun / (ll)1e10;
syousyuu_bubun %= (ll)1e10;
if (seisuu_bubun < 0 && syousyuu_bubun != 0) {
seisuu_bubun += 1;
syousyuu_bubun -= (ll)1e10;
syousyuu_bubun = abs(syousyuu_bubun);
}
cout << seisuu_bubun;
printf(".%010lld", syousyuu_bubun);
cout << endl;
return 0;
}