結果

問題 No.754 畳み込みの和
ユーザー chacoder1chacoder1
提出日時 2021-05-18 21:02:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 5,000 ms
コード長 546 bytes
コンパイル時間 1,990 ms
コンパイル使用メモリ 195,284 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 08:08:39
合計ジャッジ時間 2,774 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
5,248 KB
testcase_01 AC 77 ms
5,376 KB
testcase_02 AC 79 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
#define int long long
static const int mod=1000000007;

signed main(){
  int n;
  cin>>n;
  int a[n+2];
  int b[n+1];
  int sum=0;
  rep(i,n+1){
    cin>>a[i];
    sum+=a[i];
    sum%=mod;
  }
  a[n+1]=0;
  rep(i,n+1) cin>>b[i];  
  int ans=0;
  rep(i,n+1){   
    ans+=((b[i]*sum)%mod);
    ans%=mod;
    //cout<<b[i]*sum<<" "<<ans<<endl;
    sum-=a[n-i];
    if(sum<0) sum+=mod;
  }
  if(ans<0) ans+=mod;
  cout<<ans<<endl;
  return 0;
}
0