結果

問題 No.1172 Add Recursive Sequence
ユーザー もりをもりを
提出日時 2020-08-14 23:05:30
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3,836 ms / 4,000 ms
コード長 884 bytes
コンパイル時間 3,342 ms
コンパイル使用メモリ 212,384 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-18 22:58:08
合計ジャッジ時間 15,318 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 27 ms
5,376 KB
testcase_11 AC 25 ms
5,376 KB
testcase_12 AC 94 ms
5,376 KB
testcase_13 AC 85 ms
5,376 KB
testcase_14 AC 1,141 ms
5,376 KB
testcase_15 AC 3,836 ms
6,940 KB
testcase_16 AC 1,151 ms
5,376 KB
testcase_17 AC 3,744 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ui128 = __uint128_t;

constexpr int MOD = (int)1e9 + 7;
constexpr int MX = 100000;
constexpr int MX_K = 200;

int K, N, M, L, R;
int A[MX + 1], C[MX_K + 1];
ll res[MX + 1];
ui128 tmp;

int main() {
    scanf("%d%d%d", &K, &N, &M);
    for (int i = 0; i < K; ++i) scanf("%d", A + i);
    for (int i = 0; i < K; ++i) scanf("%d", C + i);
    for (int i = K; i < N; ++i) {
        tmp = 0;
        for (int j = 0; j < K; ++j) tmp += ll(C[j]) * A[i - 1 - j];
        A[i] = tmp % MOD;
    }
    for (int i = 0; i < M; ++i) {
        scanf("%d%d", &L, &R);
        for (int j = L; j < R; ++j) res[j] += A[j - L];
    }
    for (int i = 0; i < N; ++i) printf("%d\n", res[i] % MOD);
}
0