結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー msm1993msm1993
提出日時 2020-05-15 15:29:58
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,159 bytes
コンパイル時間 1,661 ms
コンパイル使用メモリ 171,152 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 16:22:43
合計ジャッジ時間 2,895 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

signed main(){
  int N; cin >> N;
  vector< __int128 > A( N );
  for( int i = 0; i < N; ++i ){
    string S; cin >> S;
    int neg = S[ 0 ] == '-';
    if( neg ) S = S.substr( 1 );
    for( int j = 0; j < S.size(); ++j ){
      if( S[ j ] == '.' ){
        S = S.substr( j );
        break;
      }
      A[ i ] = A[ i ] * 10 + S[ j ] - '0';
    }
    if( S[ 0 ] == '.' ) S = S.substr( 1 );
    else S = "";
    for( int j = 0; j < S.size(); ++j )
      A[ i ] = A[ i ] * 10 + S[ j ] - '0';
    for( int j = 0; j < 10 - S.size(); ++j )
      A[ i ] = A[ i ] * 10; 
    if( neg ) A[ i ] *= -1;
  }
  __int128 sum = 0;
  for( int i = 0; i < N; ++i )
    sum += A[ i ];
  int neg = 0;
  if( sum < 0 ) sum *= -1, neg = 1;
  string ans;
  while( sum )
    ans += ( char ) ( '0' + sum % 10 ),
    sum /= 10;
  reverse( ans.begin(), ans.end() );
  if( ans.empty() ){
    cout << "0.0000000000" << endl;
    exit( 0 );
  }
  if( ans.size() <= 10 )
    ans = "0." + ans;
  else
    ans = ans.substr( 0, ans.size() - 10 ) + "." + ans.substr( ans.size() - 10 );
  if( neg ) cout << "-";
  cout << ans << endl;
  return 0;
}
0