結果

問題 No.1237 EXP Multiple!
ユーザー bluemegane
提出日時 2020-09-26 07:01:42
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 874 bytes
コンパイル時間 838 ms
コンパイル使用メモリ 104,704 KB
実行使用メモリ 43,264 KB
最終ジャッジ日時 2024-06-28 16:31:23
合計ジャッジ時間 3,164 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using static System.Math;
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 = new int[n];
        for (int i = 0; i < n; i++)
        {
            var w = int.Parse(line[i]);
            if (w == 0) { Console.WriteLine(-1); goto exit; }
            else if (w >= 4) { Console.WriteLine(MOD); goto exit; }
            else a[i] = w;
        }
        getAns(n, a);
    exit:;
    }
    static void getAns(int n, int[] a)
    {
        var b = new int[] { 0, 1, 4, (int)Pow(3, 6) };
        var s = 1L;
        for (int i = 0; i < n; i++)
        {
            s *= b[a[i]];
            if (s > MOD) { Console.WriteLine(MOD); return; }
        }
        Console.WriteLine(MOD % s);
    }
}
0