結果

問題 No.1172 Add Recursive Sequence
ユーザー もりを
提出日時 2020-08-14 23:01:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 893 bytes
コンパイル時間 3,326 ms
コンパイル使用メモリ 216,596 KB
最終ジャッジ日時 2025-01-13 00:34:36
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 14 TLE * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:42: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘ll’ {aka ‘long long int’} [-Wformat=]
   32 |     for (int i = 0; i < N; ++i) printf("%d\n", res[i] % MOD);
      |                                         ~^     ~~~~~~~~~~~~
      |                                          |            |
      |                                          int          ll {aka long long int}
      |                                         %lld
main.cpp:17:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |     scanf("%d%d%d", &K, &N, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:18:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |     for (int i = 0; i < K; ++i) scanf("%d", A + i);
      |                                 ~~~~~^~~~~~~~~~~~~
main.cpp:19:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |     for (int i = 0; i < K; ++i) scanf("%d", C + i);
      |                                 ~~~~~^~~~~~~~~~~~~
main.cpp:29:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |         scanf("%d%d", &L, &R);
      |         ~~~~~^~~~~~~~~~~~~~~~

ソースコード

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;

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 tmp, res[MX + 1];

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];
            tmp %= MOD;
        }
        A[i] = tmp;
    }
    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