結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2016-04-25 15:01:43
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 843 bytes
コンパイル時間 1,242 ms
コンパイル使用メモリ 161,940 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 04:26:43
合計ジャッジ時間 2,116 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)

typedef long long ll;

ll solve(string s)
{
	int i = 0;
	ll minus = 1;
	if (s[i] == '-')
	{
		minus = -1;
		i++;
	}

	ll ret = 0;
	while (i < s.length())
	{
		if (s[i] == '.') break;
		ret = ret * 10 + s[i] - '0';
		i++;
	}

	rep(i, 0, 10) ret *= 10;
	if (i == s.length()) return minus * ret;

	i++;
	ll d = 1;
	rep(i, 0, 9) d *= 10;
	while (i < s.length())
	{
		ret += (s[i] - '0') * d;
		d /= 10;
		i++;
	}

	return minus * ret;
}

int main()
{
	/*cout << solve("123.123") << endl;
	return 0;*/

	int N; cin >> N;
	
	ll sum = 0;
	rep(i, 0, N)
	{
		string s; cin >> s;
		sum += solve(s);
	}

	string ans = to_string(sum);
	rep(i, 0, ans.length() - 10) cout << ans[i];
	cout << ".";
	rep(i, ans.length() - 10, ans.length()) cout << ans[i];
	cout << endl;
}
0