結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー koba-e964koba-e964
提出日時 2015-06-07 17:13:57
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 950 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 65,612 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-21 13:00:42
合計ジャッジ時間 1,681 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <sstream>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;

const ll M = 1e10;

int main(void){
  int n;
  cin >> n;
  ll s0 = 0, s1 = 0;
  REP(i, 0, n) {
    string line;
    ll q;
    cin >> line;
    stringstream ls;
    ls << line;
    ls >> q;
    char o = ls.get();
    ll r = 0;
    if (o == '.') {
      string s;
      ls >> s;
      while (s.length() < 10) {
	s += '0';
      }
      stringstream ss;
      ss << s;
      ss >> r;
    }
    if (line[0] == '-') {
      r = -r;
    }
    s0 += q;
    s1 += r;
  }
  ll q = s1 / M;
  s0 += q;
  s1 -= q * M;
  int sgn = s0 < 0;
  if (sgn) {
    s0 = -s0;
    s1 = -s1;
  }
  if (s0 > 0 && s1 < 0) {
    s0--;
    s1 += M;
  }
  s1 = abs(s1);
  if (sgn) {
    printf("-");
  }
  printf("%lld.%010lld\n", s0, s1);
}
0