結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー koyumeishikoyumeishi
提出日時 2014-11-28 00:56:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,368 bytes
コンパイル時間 1,197 ms
コンパイル使用メモリ 78,132 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-01 22:34:24
合計ジャッジ時間 2,143 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>

#include <queue>
#include <cmath>

using namespace std;

void func(long long &a, long long &b, string s){
	
}

int main(){
	int n;
	cin >> n;
	long long a = 0;
	long long b = 0;
	for(int i=0; i<n; i++){
		string s;
		cin >> s;

		long long sgn = 1;
		if(s[0] == '-'){
			s = s.substr(1);
			sgn = -1;
		}
		
		//cerr << s << endl;
		
		auto pos = s.find('.');
		{
			string sub = s.substr(0, pos);
			//cerr << sub << endl;
			
			stringstream ss;
			ss << sub;
			long long x;
			ss >> x;
			a += sgn * x;
		}
		if(pos != string::npos){
			string sub = s.substr(pos+1);
			
			for(int i=0; i<10; i++){
				sub += '0';
			}
			
			
			//cerr << sub.substr(0,10) << endl;
			
			stringstream ss;
			ss << sub.substr(0,10);
			long long x;
			ss >> x;
			b += sgn * x;
		}

		a += b/10000000000LL;
		b %= 10000000000LL;
	}
	if(a>0 && b<0){
		a--;
		b += 10000000000LL;
	}else if(a<0 && b>0){
		a++;
		b -= 10000000000LL;
	}
	long long sgn = a<0 || b<0 ? -1:1;
	b = abs(b);
	stringstream ss;
	ss << b;
	string bs;
	ss >> bs;
	for(int i=0; i<10; i++){
		bs = '0' + bs;
	}
	cout << (sgn<0?"-":"") << a << '.' << bs.substr(bs.size()-10,10) << endl;
	return 0;
}
0