結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー ty70ty70
提出日時 2015-06-06 16:12:46
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,860 bytes
コンパイル時間 1,233 ms
コンパイル使用メモリ 94,912 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-21 13:00:22
合計ジャッジ時間 1,986 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DIGIT 1e10

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll,ll> LL;

LL func (string s ){

	ll sign = (s[0] == '-' ? -1LL : 1LL );

	rep (i, s.length() ) if (s[i] == '.' ) s[i] = ' ';

	stringstream ss (s );
	ll integer = 0LL;
	string decimal = "";
	ss >> integer >> decimal;
	while (decimal.length() < 10 ){
		decimal += '0';
	} // end while

	stringstream tt (decimal );
	ll dec;
	tt >> dec;
	
	return LL (integer, sign*dec );
}

string ll2s (ll m ){
	stringstream ss; 
	ss << m;
	string res; ss >> res; 
	while (res.length() < 10 ){
		res = '0' + res;
	} // end while
	
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	int N; cin >> N;
	vector<LL> num(N);
	rep (i, N ){
		string s; cin >> s;
		num[i] = func (s );
	} // end rep

	ll sumi = 0LL, sumd = 0LL;

	rep (i, N ) sumi += num[i].first, sumd += num[i].second;
	
	while (sumd < 0LL ) sumi--, sumd += DIGIT;

	while (sumd >= DIGIT ) sumi++, sumd -= DIGIT;

	if (sumi < 0LL && sumd > 0LL ) sumi++, sumd = DIGIT - sumd;
	
	printf ("%lld.%010lld\n", sumi, sumd );

	return 0;
}
0