結果

問題 No.1927 AB-CD
ユーザー masayamatumasayamatu
提出日時 2022-06-21 21:01:28
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 2,036 bytes
コンパイル時間 13,291 ms
コンパイル使用メモリ 171,120 KB
実行使用メモリ 186,052 KB
最終ジャッジ日時 2024-04-22 16:38:33
合計ジャッジ時間 16,666 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
30,456 KB
testcase_01 AC 53 ms
30,208 KB
testcase_02 AC 53 ms
30,080 KB
testcase_03 AC 53 ms
30,208 KB
testcase_04 AC 90 ms
38,656 KB
testcase_05 AC 85 ms
38,400 KB
testcase_06 AC 85 ms
38,400 KB
testcase_07 AC 84 ms
38,016 KB
testcase_08 AC 66 ms
32,128 KB
testcase_09 AC 87 ms
38,784 KB
testcase_10 AC 82 ms
37,504 KB
testcase_11 AC 84 ms
38,016 KB
testcase_12 AC 74 ms
34,176 KB
testcase_13 AC 76 ms
34,688 KB
testcase_14 AC 67 ms
31,736 KB
testcase_15 AC 71 ms
32,872 KB
testcase_16 AC 88 ms
38,144 KB
testcase_17 AC 83 ms
36,796 KB
testcase_18 AC 82 ms
37,120 KB
testcase_19 AC 83 ms
37,616 KB
testcase_20 AC 90 ms
39,552 KB
testcase_21 AC 83 ms
37,632 KB
testcase_22 AC 73 ms
34,048 KB
testcase_23 AC 93 ms
40,448 KB
testcase_24 AC 97 ms
41,216 KB
testcase_25 AC 94 ms
41,088 KB
testcase_26 AC 94 ms
41,216 KB
testcase_27 AC 52 ms
30,336 KB
testcase_28 AC 51 ms
29,952 KB
testcase_29 AC 50 ms
186,052 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (93 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
//using static CompLib.CompLib;
//using DataStructure;

namespace atcoder
{
    class Program
    {
        const int intMax = 1000000000;
        const long longMax = 2000000000000000000;
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            String S = Console.ReadLine();
            long mod = 998244353;
            var list = new List<int>();
            int cnt = 0;
            for (int i = 0; i < N; i++)
            {
                if (S[i] == 'A' || S[i] == 'B') cnt++;
            }
            var comb = new Comb(N, mod);
            long ans = comb.nCk(N, cnt);
            Console.WriteLine(ans);
        }
    }
    public class Comb
    {
        private long[] fact_;
        private long[] fact_inv_;
        private long[] inv_;
        private long mod = 1000000007;

        public Comb(int SIZE, long mod = 1000000007)
        {
            this.mod = mod;
            fact_ = Enumerable.Repeat((long)1, SIZE + 1).ToArray();
            fact_inv_ = Enumerable.Repeat((long)1, SIZE + 1).ToArray();
            inv_ = Enumerable.Repeat((long)1, SIZE + 1).ToArray();
            for (int i = 2; i < SIZE + 1; i++)
            {
                fact_[i] = fact_[i - 1] * i % mod;
                inv_[i] = mod - inv_[mod % i] * (mod / i) % mod;
                fact_inv_[i] = fact_inv_[i - 1] * inv_[i] % mod;
            }
        }
        public long nCk(int n, int k)
        {
            return fact_[n] * (fact_inv_[k] * fact_inv_[n - k] % mod) % mod;
        }
        public long nHk(int n, int k)
        {
            return nCk(n + k - 1, k);
        }
        public long fact(int n)
        {
            return fact_[n];
        }
        public long fact_inv(int n)
        {
            return fact_inv_[n];
        }
        public long inv(int n)
        {
            return inv_[n];
        }
    }
}
0