提出 #34349419


ソースコード 拡げる

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const ll mod = 998244353;

ll n;

ll poww(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % mod;
    b >>= 1;
    a = (a * a) % mod;
  }
  return ans;
}

ll inv(ll x) {
  return poww(x, mod - 2);
}

ll fact(ll x) {
  ll ans = 1;
  for (ll i = 1; i <= x; i++)
    ans = (ans * i) % mod;
  return ans;
}

ll catalan(ll n) {
  ll up = fact(2 * n);
  ll down = fact(n);
  down = (down * down) % mod;
  down = (down * (n + 1)) % mod;
  down = inv(down);
  return (up * down) % mod;
}

int main()
{
  cin >> n;
  ll ans = catalan(n) * poww(2, n) % mod;
  ans = ans * fact(n) % mod;
  cout << ans;

  return 0;
}

提出情報

提出日時
問題 C - Split and Maximize
ユーザ atatomir
言語 C++ (GCC 9.2.1)
得点 600
コード長 891 Byte
結果 AC
実行時間 10 ms
メモリ 3636 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 2
AC × 25
セット名 テストケース
Sample 00_sample_01.txt, 00_sample_02.txt
All 00_sample_01.txt, 00_sample_02.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt
ケース名 結果 実行時間 メモリ
00_sample_01.txt AC 8 ms 3552 KiB
00_sample_02.txt AC 2 ms 3548 KiB
01_small_01.txt AC 2 ms 3364 KiB
01_small_02.txt AC 2 ms 3548 KiB
01_small_03.txt AC 2 ms 3548 KiB
01_small_04.txt AC 2 ms 3552 KiB
01_small_05.txt AC 2 ms 3500 KiB
02_random_01.txt AC 3 ms 3596 KiB
02_random_02.txt AC 5 ms 3556 KiB
02_random_03.txt AC 2 ms 3504 KiB
02_random_04.txt AC 6 ms 3548 KiB
02_random_05.txt AC 3 ms 3416 KiB
02_random_06.txt AC 9 ms 3556 KiB
02_random_07.txt AC 6 ms 3416 KiB
02_random_08.txt AC 3 ms 3540 KiB
02_random_09.txt AC 6 ms 3636 KiB
02_random_10.txt AC 6 ms 3560 KiB
02_random_11.txt AC 8 ms 3384 KiB
02_random_12.txt AC 6 ms 3504 KiB
02_random_13.txt AC 6 ms 3368 KiB
02_random_14.txt AC 6 ms 3428 KiB
02_random_15.txt AC 6 ms 3416 KiB
02_random_16.txt AC 9 ms 3528 KiB
02_random_17.txt AC 6 ms 3552 KiB
02_random_18.txt AC 10 ms 3368 KiB