結果

問題 No.754 畳み込みの和
ユーザー nebukuro09nebukuro09
提出日時 2018-12-02 00:08:34
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 45 ms / 5,000 ms
コード長 654 bytes
コンパイル時間 864 ms
コンパイル使用メモリ 103,628 KB
実行使用メモリ 6,220 KB
最終ジャッジ日時 2023-09-03 21:16:38
合計ジャッジ時間 1,378 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto A = (N+1).iota.map!(_ => readln.chomp.to!long).array;
    auto B = (N+1).iota.map!(_ => readln.chomp.to!long).array;

    auto b = 0;
    foreach (i; 0..N+1) b = (b + B[i]) % MOD;
    long ans = 0;

    foreach (i; 0..N+1) {
        ans += A[i] * b % MOD;
        ans %= MOD;
        b -= B[N-i];
        b %= MOD;
    }

    ans = (ans + MOD) % MOD;
    ans.writeln;
}
0