結果

問題 No.754 畳み込みの和
ユーザー tentententen
提出日時 2021-02-09 08:40:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 816 ms / 5,000 ms
コード長 651 bytes
コンパイル時間 2,089 ms
コンパイル使用メモリ 71,424 KB
実行使用メモリ 65,116 KB
最終ジャッジ日時 2023-09-20 19:12:09
合計ジャッジ時間 6,222 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 786 ms
64,888 KB
testcase_01 AC 774 ms
64,540 KB
testcase_02 AC 816 ms
65,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt() + 1;
        int[] as = new int[n];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
            sum += as[i];
        }
        sum %= MOD;
        long ans = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            ans += sum * x % MOD;
            ans %= MOD;
            sum += MOD - as[n - i - 1];
            sum %= MOD;
        }
        System.out.println(ans);
    }
}
0