結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー ku_material_roku_material_ro
提出日時 2016-09-29 15:23:21
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,051 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 65,436 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 07:42:55
合計ジャッジ時間 3,836 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;


int main(){
	string s;
	string si;
	string sd;
	string ss="";
	int n;
	int keta;
	int kuriagari;
	long long in = 0;
	long long de = 0;
	long long toi = 0;
	long long tod = 0;
	int index;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		index = (int)s.find(".");
		if (index == -1){
			in = stoi(s);
			de = 0;
		}
		else{
			si = s.substr(0, index);
			sd = s.substr(index + 1, s.length() - index);
			for (int is = 10 - sd.length(); is>0; is--){
				sd += "0";
			}
			in = stoi(si);
			de = stoi(sd);
		}
		toi += in;
		tod += de;
	}
	if (tod > 0){
		keta = 10 - ((int)log10(tod) + 1);
	}
	else{
		keta = 9;
	}
	if (keta<0){
		kuriagari = tod / 10000000000;
		toi += kuriagari;
		tod -= kuriagari * 10000000000;
		if (tod > 0){
			keta = 10 - ((int)log10(tod) + 1);
		}
		else{
			keta = 9;
		}

	}
	//cout << keta << endl;
	while (keta > 0){
		ss += "0";
		keta--;
	}
	//cout << ss << endl;
	cout << toi << "." << ss << tod << endl;
	return 0;
}
0