結果

問題 No.1325 Subsequence Score
ユーザー iiljjiiljj
提出日時 2020-12-22 00:52:57
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 2,099 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 32,132 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 12:17:43
合計ジャッジ時間 1,807 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
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 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
4,348 KB
testcase_29 WA -
testcase_30 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:7:15: warning: implicit declaration of function 'getc_unlocked' [-Wimplicit-function-declaration]
    7 |         tmp = getc_unlocked(stdin);                                                                                    \
      |               ^~~~~~~~~~~~~
main.c:24:5: note: in expansion of macro 'rd_int'
   24 |     rd_int(n, k);
      |     ^~~~~~
main.c:17:19: warning: implicit declaration of function 'putc_unlocked' [-Wimplicit-function-declaration]
   17 |     while (ptr--) putc_unlocked(buf[ptr] + '0', stdout);
      |                   ^~~~~~~~~~~~~
main.c:29:9: note: in expansion of macro 'wt_int'
   29 |         wt_int(a, buf, ptr);
      |         ^~~~~~
main.c:55:5: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   55 |     _exit(0);
      |     ^~~~~
      |     _Exit

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <stdio.h>

#define rd_int(var, tmp)                                                                                               \
    for (;;) {                                                                                                         \
        tmp = getc_unlocked(stdin);                                                                                    \
        if (tmp < '0' || tmp > '9') break;                                                                             \
        var = var * 10 + tmp - '0';                                                                                    \
    }

#define wt_int(var, buf, ptr)                                                                                          \
    while (var) {                                                                                                      \
        buf[ptr++] = var % 10;                                                                                         \
        var /= 10;                                                                                                     \
    }                                                                                                                  \
    while (ptr--) putc_unlocked(buf[ptr] + '0', stdout);

// 998244353
int main() {
    long k, n = 0, a, ret = 0, ptr = 0;
    char buf[9];

    rd_int(n, k);
    if (n == 1) {
        a = 0;
        rd_int(a, k);
        a %= 998244353;
        wt_int(a, buf, ptr);
        return 0;
    }
    for (int i = 0; i < n; ++i) {
        a = 0;
        rd_int(a, k);
        ret += a * (i + 2);
        if (ret >= 998244353) ret %= 998244353;
    }

    // int retcp = ret;
    // wt_int(retcp, buf, ptr);
    // ptr = 0;

    int t = n - 2;
    a = 2;
    while (t) {
        if (t & 1) {
            ret *= a;
            if (ret >= 998244353) ret %= 998244353;
        }
        t >>= 1, a *= a;
        if (a >= 998244353) a %= 998244353;
    }
    wt_int(ret, buf, ptr);

    _exit(0);
    // return 0;
}
0