結果

問題 No.754 畳み込みの和
ユーザー vis103vis103
提出日時 2018-12-14 12:21:32
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 101 ms / 5,000 ms
コード長 1,017 bytes
コンパイル時間 3,691 ms
コンパイル使用メモリ 106,152 KB
実行使用メモリ 28,788 KB
最終ジャッジ日時 2023-10-25 09:56:39
合計ジャッジ時間 1,723 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
28,788 KB
testcase_01 AC 101 ms
28,776 KB
testcase_02 AC 100 ms
28,788 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine()) + 1;

        ulong[] a = new ulong[n];
        ulong[] b = new ulong[n];
        ulong bAccumulation = 0;
        ulong Remainder = 1000000007;

        for (int i = 0; i < n; i++)
        {
            b[i] = ulong.Parse(Console.ReadLine());
            bAccumulation += b[i];
            bAccumulation %= Remainder;
        }

        for (int i = 0; i < n; i++)
        {
            a[i] = ulong.Parse(Console.ReadLine());
        }

        ulong Sum = 0;

        for(int i = 0; i < n; i++)
        {
            Sum += a[i] * bAccumulation;

            Sum %= Remainder;
            if (bAccumulation < b[b.Length - i - 1])
            {
                bAccumulation += Remainder;
                bAccumulation -= b[b.Length - i - 1];
            }
            else
            {
                bAccumulation -= b[b.Length - i - 1];
            }

        }

        Console.WriteLine(Sum);
    }
}

0