結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー koyumeishi
提出日時 2014-11-28 00:04:39
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,191 bytes
コンパイル時間 994 ms
コンパイル使用メモリ 82,020 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-01-03 09:41:11
合計ジャッジ時間 2,051 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 12
権限があれば一括ダウンロードができます

ソースコード

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;
	}
	stringstream ss;
	ss << b;
	string bs;
	ss >> bs;
	for(int i=0; i<10; i++){
		bs = '0' + bs;
	}
	cout << a << '.' << bs.substr(bs.size()-10,10) << endl;
	return 0;
}
0