結果

問題 No.1325 Subsequence Score
コンテスト
ユーザー iiljj
提出日時 2020-12-22 00:52:57
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 2,099 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 118 ms
コンパイル使用メモリ 42,008 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-22 20:21:52
合計ジャッジ時間 1,918 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 2 WA * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:55:5: warning: implicit declaration of function '_exit' [-Wimplicit-function-declaration]
   55 |     _exit(0);
      |     ^~~~~
main.c:55:5: warning: incompatible implicit declaration of built-in function '_exit' [-Wbuiltin-declaration-mismatch]

ソースコード

diff #
raw source code

#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