結果

問題 No.1325 Subsequence Score
ユーザー iiljjiiljj
提出日時 2020-12-22 00:41:46
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 1,961 bytes
コンパイル時間 568 ms
コンパイル使用メモリ 30,280 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 12:16:33
合計ジャッジ時間 1,702 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 0 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 0 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 16 ms
4,348 KB
testcase_14 AC 5 ms
4,348 KB
testcase_15 AC 13 ms
4,348 KB
testcase_16 AC 15 ms
4,348 KB
testcase_17 AC 7 ms
4,348 KB
testcase_18 AC 5 ms
4,348 KB
testcase_19 AC 16 ms
4,348 KB
testcase_20 AC 3 ms
4,348 KB
testcase_21 AC 6 ms
4,348 KB
testcase_22 AC 8 ms
4,348 KB
testcase_23 AC 17 ms
4,348 KB
testcase_24 AC 18 ms
4,348 KB
testcase_25 AC 18 ms
4,348 KB
testcase_26 AC 17 ms
4,348 KB
testcase_27 AC 16 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:5:15: warning: implicit declaration of function 'getc_unlocked' [-Wimplicit-function-declaration]
    5 |         tmp = getc_unlocked(stdin);                                                                                    \
      |               ^~~~~~~~~~~~~
main.c:22:5: note: in expansion of macro 'rd_int'
   22 |     rd_int(n, k);
      |     ^~~~~~
main.c:15:19: warning: implicit declaration of function 'putc_unlocked' [-Wimplicit-function-declaration]
   15 |     while (ptr--) putc_unlocked(buf[ptr] + '0', stdout);
      |                   ^~~~~~~~~~~~~
main.c:27:9: note: in expansion of macro 'wt_int'
   27 |         wt_int(a, buf, ptr);
      |         ^~~~~~

ソースコード

diff #

#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);
        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;
            ret %= 998244353;
        }
        t >>= 1, a *= a;
        a %= 998244353;
    }
    wt_int(ret, buf, ptr);

    return 0;
}
0