結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー くれちーくれちー
提出日時 2017-05-03 18:21:31
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 2,271 bytes
コンパイル時間 1,138 ms
コンパイル使用メモリ 31,152 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-12 07:59:35
合計ジャッジ時間 1,650 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REP1(i, n) for (ll i = 1; i <= n; i++)
#define RREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define RREP1(i, n) for (ll i = n; i >= 1; i--)
#define FOR(i, a, b, c) for (ll i = a; i <= b; i += c)
#define RFOR(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
#define SORT(t, a, n) qsort(a, n, sizeof(t), ({ int _f (const void *_a, const void *_b) { return *(t *)_a - *(t *)_b; } _f; }))
#define RSORT(t, a, n) qsort(a, n, sizeof(t), ({ int _f (const void *_a, const void *_b) { return *(t *)_b - *(t *)_a; } _f; }))
#define SUM(a, n) ({ ll _s = 0; REP(_i, n) _s += a[_i]; _s; })
#define CNT(x, a, n) ({ ll _c = 0; REP(_i, n) if (a[_i] == x) _c++; _c; })
#define MAXM(t, a, n) ({ t _m = a[0]; REP(_i, n) _m = MAX(_m, a[_i]); _m; })
#define MINM(t, a, n) ({ t _m = a[0]; REP(_i, n) _m = MIN(_m, a[_i]); _m; })
#define INF 1145141919
typedef long long ll;

int main() {
    int n;
    scanf("%d", &n);
    ll sum = 0;
    while (n--) {
        char a[24];
        scanf("%s", a);
        int len = strlen(a);
        if (!CNT('.', a, len)) {
            a[len] = '.';
            a[len + 1] = '\0';
            len++;
        }
        bool afterp = false;
        int cntafterp = 0;
        REP(i, len + 1) {
            if (cntafterp == 10) break;
            if (afterp) {
                if (a[i] == '\0') {
                    a[i] = '0';
                    a[i + 1] = '\0';
                    len++;
                }
                cntafterp++;
            }
            if (a[i] == '.') afterp = true;
        }
        ll tmpsum = 0;
        int rank = 0;
        RREP(i, len) {
            if (i == 0 && a[i] == '-') {
                tmpsum *= -1;
                break;
            }
            if (a[i] != '.') {
                tmpsum += (a[i] - '0') * (ll)pow(10, rank);
                rank++;
            }
        }
        sum += tmpsum;
    }
    ll sumbeforep = sum / 10000000000;
    ll sumafterp = sum - sumbeforep * 10000000000;
    if (sumafterp < 0) sumafterp *= -1;
    printf("%lld.%010lld\n", sumbeforep, sumafterp);
    return 0;
}
0