結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー koyumeishikoyumeishi
提出日時 2014-11-27 23:57:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,176 bytes
コンパイル時間 667 ms
コンパイル使用メモリ 76,968 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-01 22:29:58
合計ジャッジ時間 1,887 ms
ジャッジサーバーID
(参考情報)
judge16 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 WA -
testcase_17 WA -
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,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 WA -
testcase_28 AC 1 ms
4,380 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;
	}
	stringstream ss;
	ss << b;
	string bs;
	ss >> bs;
	for(int i=0; i<10; i++){
		bs += '0';
	}
	cout << a << '.' << bs.substr(0,10) << endl;
	return 0;
}
0