結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー naimonon77naimonon77
提出日時 2016-09-15 11:03:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,767 bytes
コンパイル時間 1,509 ms
コンパイル使用メモリ 166,564 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-21 13:25:03
合計ジャッジ時間 2,797 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 WA -
testcase_18 AC 1 ms
4,384 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0