結果
| 問題 |
No.1927 AB-CD
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-06-21 21:01:28 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 100 ms / 2,000 ms |
| コード長 | 2,036 bytes |
| コンパイル時間 | 9,781 ms |
| コンパイル使用メモリ | 171,232 KB |
| 実行使用メモリ | 186,008 KB |
| 最終ジャッジ日時 | 2024-10-14 15:49:31 |
| 合計ジャッジ時間 | 11,091 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (101 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/
ソースコード
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];
}
}
}