結果

問題 No.797 Noelちゃんとピラミッド
ユーザー keymoonkeymoon
提出日時 2019-03-15 21:50:59
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 175 ms / 2,000 ms
コード長 1,413 bytes
コンパイル時間 3,037 ms
コンパイル使用メモリ 103,600 KB
実行使用メモリ 32,164 KB
最終ジャッジ日時 2023-09-14 13:26:53
合計ジャッジ時間 12,071 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
21,880 KB
testcase_01 AC 63 ms
23,848 KB
testcase_02 AC 64 ms
21,780 KB
testcase_03 AC 170 ms
32,088 KB
testcase_04 AC 170 ms
28,072 KB
testcase_05 AC 170 ms
32,112 KB
testcase_06 AC 171 ms
32,104 KB
testcase_07 AC 171 ms
30,168 KB
testcase_08 AC 169 ms
32,152 KB
testcase_09 AC 169 ms
30,080 KB
testcase_10 AC 170 ms
30,168 KB
testcase_11 AC 171 ms
32,056 KB
testcase_12 AC 175 ms
30,092 KB
testcase_13 AC 172 ms
30,072 KB
testcase_14 AC 170 ms
30,008 KB
testcase_15 AC 171 ms
30,080 KB
testcase_16 AC 170 ms
30,176 KB
testcase_17 AC 172 ms
32,164 KB
testcase_18 AC 171 ms
30,172 KB
testcase_19 AC 170 ms
30,080 KB
testcase_20 AC 170 ms
29,976 KB
testcase_21 AC 168 ms
29,976 KB
testcase_22 AC 171 ms
30,192 KB
testcase_23 AC 141 ms
30,536 KB
testcase_24 AC 93 ms
23,588 KB
testcase_25 AC 131 ms
27,344 KB
testcase_26 AC 129 ms
27,100 KB
testcase_27 AC 168 ms
29,860 KB
testcase_28 AC 160 ms
29,368 KB
testcase_29 AC 84 ms
22,856 KB
testcase_30 AC 91 ms
23,416 KB
testcase_31 AC 142 ms
28,408 KB
testcase_32 AC 100 ms
23,384 KB
testcase_33 AC 129 ms
27,248 KB
testcase_34 AC 113 ms
24,856 KB
testcase_35 AC 171 ms
32,092 KB
testcase_36 AC 82 ms
22,692 KB
testcase_37 AC 156 ms
29,524 KB
testcase_38 AC 158 ms
29,588 KB
testcase_39 AC 128 ms
27,216 KB
testcase_40 AC 79 ms
22,624 KB
testcase_41 AC 86 ms
25,048 KB
testcase_42 AC 125 ms
25,036 KB
testcase_43 AC 62 ms
21,804 KB
testcase_44 AC 63 ms
21,840 KB
testcase_45 AC 63 ms
21,836 KB
testcase_46 AC 62 ms
21,760 KB
testcase_47 AC 62 ms
21,836 KB
testcase_48 AC 63 ms
23,856 KB
testcase_49 AC 62 ms
21,788 KB
testcase_50 AC 62 ms
21,780 KB
testcase_51 AC 62 ms
21,880 KB
testcase_52 AC 63 ms
21,836 KB
testcase_53 AC 63 ms
23,820 KB
testcase_54 AC 62 ms
21,924 KB
testcase_55 AC 62 ms
21,780 KB
testcase_56 AC 64 ms
21,728 KB
testcase_57 AC 63 ms
23,968 KB
testcase_58 AC 63 ms
21,768 KB
testcase_59 AC 62 ms
21,804 KB
testcase_60 AC 63 ms
23,932 KB
testcase_61 AC 63 ms
21,804 KB
testcase_62 AC 63 ms
21,884 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.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using System.Runtime.CompilerServices;


static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine().Trim());
        var a = Console.ReadLine().Trim().Split().Select(long.Parse).ToList();
        //var a = Enumerable.Range(0, n).ToList();
        if (a.Count != n) throw new Exception();
        long res = a[0];
        long mul = 1;
        for (int i = 1; i < a.Count; i++)
        {
            mul = ((mul * (n - i)) % 1000000007) * Power(i, 1000000007 - 2);
            mul %= 1000000007;
            //Console.WriteLine(mul);
            res += mul * a[i];
            res %= 1000000007;
        }
        Console.WriteLine(res);
    }

    static long Power(long n, long m)
    {
        const int mod = 1000000007;
        long pow = n;
        long res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res = (res * pow) % mod;
            pow = (pow * pow) % mod;
            m >>= 1;
        }
        return res;
    }
}
0