結果

問題 No.1681 +-*
ユーザー bluemegane
提出日時 2021-09-18 10:29:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 845 bytes
コンパイル時間 3,891 ms
コンパイル使用メモリ 110,752 KB
実行使用メモリ 46,680 KB
最終ジャッジ日時 2024-06-30 07:38:15
合計ジャッジ時間 7,452 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Numerics;
using System;

public class Hello
{
    public static int MOD = 1000000007;
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, a);
    }
    static void getAns(int n, int[] a)
    {
        var ans = 0L;
        var t = 1L;
        for (int i = 0; i < n; i++)
        {
            t *= a[i];
            t %= MOD;
            long t2;
            if (n - 2 - i < 0) t2 = 1L;
            else
            {
                t2 = (long)BigInteger.ModPow(3, n - 2 - i, MOD) * 2L;
                t2 %= MOD;
            }
            t2 *= t;
            t2 %= MOD;
            ans += t2;
            ans %= MOD;
        }
        Console.WriteLine(ans);
    }
}
0