結果

問題 No.754 畳み込みの和
ユーザー YamaKasaYamaKasa
提出日時 2019-02-12 00:22:27
言語 Java19
(openjdk 21)
結果
AC  
実行時間 714 ms / 5,000 ms
コード長 630 bytes
コンパイル時間 2,804 ms
コンパイル使用メモリ 73,604 KB
実行使用メモリ 67,016 KB
最終ジャッジ日時 2023-09-27 11:07:47
合計ジャッジ時間 6,775 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 671 ms
66,976 KB
testcase_01 AC 714 ms
66,656 KB
testcase_02 AC 682 ms
67,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt() + 1;
		long[] a = new long[n];
		long[] b = new long[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		for(int i = 0; i < n; i++) {
			b[i] = sc.nextLong();
		}
		sc.close();
		long mod = (long)Math.pow(10, 9) + 7;
		long ans = 0;
		long[] B = new long[n];
		B[0] = b[0];
		for(int i = 1; i < n; i++) {
			B[i] += B[i - 1] + b[i];
			B[i] %= mod;
		}
		for(int i = 0; i < n; i++) {
			ans += a[i] * B[n - i - 1];
			ans %= mod;
		}
		System.out.println(ans);
	}
}
0