結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー hanorverhanorver
提出日時 2016-05-25 13:50:47
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 800 bytes
コンパイル時間 740 ms
コンパイル使用メモリ 61,072 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-16 16:34:31
合計ジャッジ時間 2,019 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>

int main() {
	int n;

	std::cin >> n;

	long long ans = 0;

	for (int i = 0; i < n; i++) {
		std::string no;
		std::cin >> no;

		int position = 0;
		auto point = std::find(no.begin(), no.end(), '.');
		long long num;

		// 入力が小数なら小数点を取り整数化する
		if (point != no.end()) {
			position = point - no.begin();
			no.erase(no.find('.'), 1);
			num = std::stoll(no);
			// 0.000000001を1の位になるように調整
			for (int j = 0; j < 10 - (no.length() - position); j++) {
				num *= 10;
			}
		} else {
			num = std::stoll(no);
			for (int i = 0; i < 10; i++) {
				num *= 10;
			}
		}
		ans += num;
	}

	std::string s = std::to_string(ans);
	s.insert(s.length() - 10, ".");

	std::cout << s << std::endl;
}
0