結果

問題 No.1336 Union on Blackboard
ユーザー keymoonkeymoon
提出日時 2021-01-15 21:25:22
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 2,819 bytes
コンパイル時間 2,414 ms
コンパイル使用メモリ 106,124 KB
実行使用メモリ 23,772 KB
最終ジャッジ日時 2023-08-17 16:00:13
合計ジャッジ時間 5,843 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
23,772 KB
testcase_01 AC 64 ms
21,776 KB
testcase_02 AC 65 ms
21,596 KB
testcase_03 AC 65 ms
23,684 KB
testcase_04 AC 65 ms
21,712 KB
testcase_05 AC 66 ms
23,752 KB
testcase_06 AC 66 ms
21,616 KB
testcase_07 AC 65 ms
23,680 KB
testcase_08 AC 65 ms
21,736 KB
testcase_09 AC 65 ms
23,512 KB
testcase_10 AC 66 ms
23,580 KB
testcase_11 AC 66 ms
23,648 KB
testcase_12 AC 67 ms
21,712 KB
testcase_13 AC 68 ms
23,664 KB
testcase_14 AC 68 ms
23,736 KB
testcase_15 AC 67 ms
23,648 KB
testcase_16 AC 67 ms
21,620 KB
testcase_17 AC 66 ms
21,600 KB
testcase_18 AC 67 ms
23,752 KB
testcase_19 AC 65 ms
23,736 KB
testcase_20 AC 65 ms
21,668 KB
testcase_21 AC 66 ms
23,644 KB
testcase_22 AC 67 ms
23,532 KB
testcase_23 AC 66 ms
21,548 KB
testcase_24 AC 68 ms
23,660 KB
testcase_25 AC 66 ms
21,544 KB
testcase_26 AC 66 ms
21,540 KB
testcase_27 AC 66 ms
21,712 KB
testcase_28 AC 65 ms
23,760 KB
testcase_29 AC 66 ms
23,660 KB
testcase_30 AC 63 ms
21,696 KB
testcase_31 AC 66 ms
21,780 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int t = int.Parse(Console.ReadLine());
        for (int i = 0; i < t; i++)
        {
            int n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            ModInt cur = a[0];
            for (int j = 1; j < n; j++)
            {
                cur = cur * a[j] + cur + a[j];
            }
            Console.WriteLine(cur);
        }
    }
}


struct ModInt
{
    public const int Mod = 1000000007;
    const long POSITIVIZER = ((long)Mod) << 31;
    long Data;
    public ModInt(long data) { if ((Data = data % Mod) < 0) Data += Mod; }
    public static implicit operator long(ModInt modInt) => modInt.Data;
    public static implicit operator ModInt(long val) => new ModInt(val);
    public static ModInt operator +(ModInt a, int b) => new ModInt() { Data = (a.Data + b + POSITIVIZER) % Mod };
    public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);
    public static ModInt operator +(ModInt a, ModInt b) { long res = a.Data + b.Data; return new ModInt() { Data = res >= Mod ? res - Mod : res }; }
    public static ModInt operator -(ModInt a, int b) => new ModInt() { Data = (a.Data - b + POSITIVIZER) % Mod };
    public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);
    public static ModInt operator -(ModInt a, ModInt b) { long res = a.Data - b.Data; return new ModInt() { Data = res < 0 ? res + Mod : res }; }
    public static ModInt operator *(ModInt a, int b) => new ModInt(a.Data * b);
    public static ModInt operator *(ModInt a, long b) => a * new ModInt(b);
    public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % Mod };
    public static ModInt operator /(ModInt a, ModInt b) => new ModInt() { Data = a.Data * GetInverse(b) % Mod };
    public static bool operator ==(ModInt a, ModInt b) => a.Data == b.Data;
    public static bool operator !=(ModInt a, ModInt b) => a.Data != b.Data;
    public override string ToString() => Data.ToString();
    public override bool Equals(object obj) => (ModInt)obj == this;
    public override int GetHashCode() => (int)Data;
    static long GetInverse(long a)
    {
        long div, p = Mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1;
        while (true)
        {
            if (p == 1) return x2 + Mod; div = a / p; x1 -= x2 * div; y1 -= y2 * div; a %= p;
            if (a == 1) return x1 + Mod; div = p / a; x2 -= x1 * div; y2 -= y1 * div; p %= a;
        }
    }
}
0