結果

問題 No.391 CODING WAR
ユーザー mbanmban
提出日時 2017-01-11 10:07:01
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 2,265 bytes
コンパイル時間 2,205 ms
コンパイル使用メモリ 104,368 KB
実行使用メモリ 22,764 KB
最終ジャッジ日時 2023-08-23 06:57:50
合計ジャッジ時間 6,703 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,824 KB
testcase_01 AC 57 ms
20,724 KB
testcase_02 AC 58 ms
20,772 KB
testcase_03 RE -
testcase_04 AC 57 ms
20,772 KB
testcase_05 AC 59 ms
20,668 KB
testcase_06 AC 58 ms
22,764 KB
testcase_07 WA -
testcase_08 AC 58 ms
20,840 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;


class Magatro
{
    static Scanner sc = new Scanner();
    static long N, M;
    const int Mod = 1000000007;
    static void Main()
    {
        Scan();
        Solve();
    }
    static void Solve()
    {
        long ans = 0;
        for(int i = 0; i <= M; i++)
        {
            if (i % 2 == 0)
            {
                ans  += mCn(i) * MyPow(M - i, N, Mod) % Mod;
            }
            else
            {
                ans -= mCn(i) * MyPow(M - i, N, Mod) % Mod;
            }
        }
        Console.WriteLine(ans%Mod);
    }
    static void Scan()
    {
        N = sc.NextInt();
        M = sc.NextInt();
    }
    static long MyPow(long a,long b,long mod)
    {
        long res = 1;
        while (b > 0)
        {
            if (b % 2 == 0)
            {
                a = (a * a) % mod;
                b /= 2;
            }
            else
            {
                res = (res * a) % mod;
                b--;
            }
        }
        return res;
    }
    static long mCn(int n)
    {
        long mkaijou = Kaijou(M);
        long bunbo =( Kaijou(M - n) * Kaijou(n)) % Mod;
        return (mkaijou * MyPow(bunbo, Mod - 2, Mod)) % Mod;
    }
    static long Kaijou(long n)
    {
        if (n == 0) return 1;
        return n * Kaijou(n - 1) % Mod;
    }
}
public class Scanner
{
    public string[] S;
    private int Index;
    private char Separator;
    public Scanner(char separator=' ')
    {
        Index = 0;
        Separator = separator;
    }
    private string[] Line()
    {
        return Console.ReadLine().Split(Separator);
    }
    public string Next()
    {
        string result;
        if (S == null || Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
}
0