結果

問題 No.1681 +-*
ユーザー bluemeganebluemegane
提出日時 2021-09-18 10:29:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 220 ms / 2,000 ms
コード長 845 bytes
コンパイル時間 2,517 ms
コンパイル使用メモリ 67,132 KB
実行使用メモリ 42,932 KB
最終ジャッジ日時 2023-09-12 19:57:50
合計ジャッジ時間 7,229 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
20,868 KB
testcase_01 AC 60 ms
22,884 KB
testcase_02 AC 65 ms
20,896 KB
testcase_03 AC 66 ms
21,092 KB
testcase_04 AC 67 ms
20,912 KB
testcase_05 AC 198 ms
37,992 KB
testcase_06 AC 202 ms
36,124 KB
testcase_07 AC 202 ms
38,004 KB
testcase_08 AC 219 ms
40,656 KB
testcase_09 AC 220 ms
42,732 KB
testcase_10 AC 216 ms
40,696 KB
testcase_11 AC 215 ms
40,752 KB
testcase_12 AC 217 ms
42,704 KB
testcase_13 AC 134 ms
28,560 KB
testcase_14 AC 220 ms
42,932 KB
testcase_15 AC 59 ms
20,860 KB
testcase_16 AC 57 ms
22,840 KB
testcase_17 AC 219 ms
40,704 KB
testcase_18 AC 218 ms
40,648 KB
testcase_19 AC 213 ms
40,728 KB
権限があれば一括ダウンロードができます

ソースコード

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