結果

問題 No.1172 Add Recursive Sequence
ユーザー 👑 NachiaNachia
提出日時 2020-10-07 16:52:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 748 ms / 4,000 ms
コード長 795 bytes
コンパイル時間 1,555 ms
コンパイル使用メモリ 166,924 KB
実行使用メモリ 315,972 KB
最終ジャッジ日時 2023-09-27 09:19:09
合計ジャッジ時間 6,520 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,332 KB
testcase_01 AC 2 ms
5,316 KB
testcase_02 AC 3 ms
5,352 KB
testcase_03 AC 2 ms
5,592 KB
testcase_04 AC 2 ms
5,416 KB
testcase_05 AC 2 ms
5,336 KB
testcase_06 AC 10 ms
10,080 KB
testcase_07 AC 9 ms
9,784 KB
testcase_08 AC 8 ms
9,736 KB
testcase_09 AC 9 ms
10,088 KB
testcase_10 AC 77 ms
58,572 KB
testcase_11 AC 81 ms
62,856 KB
testcase_12 AC 68 ms
55,608 KB
testcase_13 AC 65 ms
54,040 KB
testcase_14 AC 578 ms
315,916 KB
testcase_15 AC 397 ms
315,972 KB
testcase_16 AC 748 ms
315,888 KB
testcase_17 AC 603 ms
315,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

const ULL M=1000000007;

int K,N,Q;
ULL a[200],C[200];
ULL A[100001][200]={};
ULL G[100001][200]={};

int main(){
 cin>>K>>N>>Q;
 rep(i,K) cin>>a[i];
 rep(i,K) cin>>C[i]; reverse(C,C+K);

 A[0][0]=1;
 for(int i=1; i<=N; i++){
  rep(j,K-1) A[i][j+1]=A[i-1][j];
  rep(j,K) A[i][j]=(A[i][j]+A[i-1][K-1]*C[j])%M;
 }

 rep(q,Q){
  int l,r; cin>>l>>r;
  rep(i,K) G[l][i]=(G[l][i]+A[0][i])%M;
  rep(i,K) G[r][i]=(G[r][i]+M-A[r-l][i])%M;
 }

 for(int i=1; i<=N; i++){
  rep(j,K-1) G[i][j+1]=(G[i][j+1]+G[i-1][j])%M;
  rep(j,K) G[i][j]=(G[i][j]+G[i-1][K-1]*C[j])%M;
 }

 rep(i,N){
  ULL ans=0;
  rep(j,K) ans=(ans+G[i][j]*a[j])%M;
  cout<<ans<<endl;
 }

 return 0;
}
0