結果

問題 No.1172 Add Recursive Sequence
ユーザー しのしの
提出日時 2020-08-23 18:45:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,451 ms / 4,000 ms
コード長 825 bytes
コンパイル時間 2,432 ms
コンパイル使用メモリ 210,156 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-05 21:53:36
合計ジャッジ時間 14,159 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 29 ms
4,376 KB
testcase_11 AC 26 ms
4,376 KB
testcase_12 AC 99 ms
4,380 KB
testcase_13 AC 89 ms
4,380 KB
testcase_14 AC 1,133 ms
4,380 KB
testcase_15 AC 3,451 ms
4,384 KB
testcase_16 AC 1,179 ms
4,380 KB
testcase_17 AC 3,434 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
using namespace std;

using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
const int MAX = 1e5;
const int MOD = 1e9+7;
using uint = unsigned int;

inline uint add_mod(uint a, uint b) {
  return (a += b) >= MOD ? a - MOD : a;
}

uint mul(uint x,uint y){
  return 1ULL*x*y%MOD;
}

uint xs[MAX]={};
uint as[MAX]={};
uint cs[MAX]={};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int k,n,m;
  cin>>k>>n>>m;
  for(int i=0;i<k;i++) cin>>as[i];
  for(int i=0;i<k;i++) cin>>cs[i];

  for(int i=k;i<n;i++)
    for(int j=0;j<k;j++)
      as[i]=add_mod(as[i],mul(cs[j],as[i-(j+1)]));

  for(int i=0;i<m;i++){
    int l,r;
    cin>>l>>r;
    for(int k=l;k<r;k++) xs[k]=add_mod(xs[k],as[k-l]);
  }

  for(int i=0;i<n;i++) cout<<xs[i]<<newl;
  return 0;
}
0