Submission #72411578


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
const int MX=20100100,md=998244353;
int n,m;
long long F[MX],coef2[MX];
long long pw(long long a, int b) {
  if (b==0) return 1LL;
  if (b&1) return (pw(a,b-1)*a)%md;
  long long x=pw(a,b/2);
  return (x*x)%md;
}
int main() {
  scanf("%d%d",&n,&m);
  for (int i=F[0]=1; i<=2*n; i++) F[i]=(F[i-1]*i)%md;
  if (m>n) { puts("0"); return 0; }
  int i=m;
  if ((i&1)!=(n&1)) ++i;
  int rst=(n-i)/2;
  long long coef1=F[i+m-1]*pw(F[2*m-1],md-2)%md*pw(F[rst],md-2)%md;
  coef2[n]=pw(F[n-m],md-2)%md;
  for (int i=n-2; i>=m; i-=2) {
    rst=(n-i)/2;
    coef2[i]=coef2[i+2]*(i+2-m)%md*(i+1-m)%md*(rst+m-1LL)%md;
  }
  long long ans=(coef1*coef2[i])%md;
  coef1=coef1*rst%md;
  for (i+=2; i<=n; i+=2) {
    rst=(n-i)/2;
    coef1=coef1*(i+m-2LL)%md*(i+m-1LL)%md;
    ans=(ans+coef1*coef2[i])%md;
    coef1=coef1*rst%md;
  }
  printf("%lld\n",(ans*pw(2,m))%md);
  return 0;
}

Submission Info

Submission Time
Task C - ABS Ball
User Ra16bit
Language C++23 (GCC 15.2.0)
Score 600
Code Size 947 Byte
Status AC
Exec Time 290 ms
Memory 238044 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 37
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_min_01.txt, 01_min_02.txt, 01_min_03.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 03_random_01.txt, 03_random_02.txt, 03_random_03.txt, 03_random_04.txt, 03_random_05.txt, 03_random_06.txt, 03_random_07.txt, 03_random_08.txt, 03_random_09.txt, 03_random_10.txt, 03_random_11.txt, 03_random_12.txt, 03_random_13.txt, 03_random_14.txt, 03_random_15.txt, 04_max_01.txt, 04_max_02.txt, 04_max_03.txt, 04_max_04.txt, 04_max_05.txt, 04_max_06.txt, 05_n_large_01.txt, 05_n_large_02.txt, 05_n_large_03.txt, 05_n_large_04.txt, 05_n_large_05.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 1 ms 3860 KiB
00_sample_02.txt AC 1 ms 3796 KiB
00_sample_03.txt AC 216 ms 199192 KiB
01_min_01.txt AC 1 ms 3788 KiB
01_min_02.txt AC 1 ms 3732 KiB
01_min_03.txt AC 1 ms 3696 KiB
02_small_01.txt AC 1 ms 3624 KiB
02_small_02.txt AC 1 ms 3676 KiB
02_small_03.txt AC 1 ms 3624 KiB
02_small_04.txt AC 1 ms 3624 KiB
02_small_05.txt AC 1 ms 3660 KiB
03_random_01.txt AC 85 ms 99068 KiB
03_random_02.txt AC 227 ms 202776 KiB
03_random_03.txt AC 30 ms 28456 KiB
03_random_04.txt AC 216 ms 194840 KiB
03_random_05.txt AC 147 ms 132692 KiB
03_random_06.txt AC 62 ms 58212 KiB
03_random_07.txt AC 169 ms 154260 KiB
03_random_08.txt AC 152 ms 160972 KiB
03_random_09.txt AC 196 ms 180372 KiB
03_random_10.txt AC 108 ms 125848 KiB
03_random_11.txt AC 110 ms 128664 KiB
03_random_12.txt AC 273 ms 227268 KiB
03_random_13.txt AC 197 ms 177212 KiB
03_random_14.txt AC 16 ms 16660 KiB
03_random_15.txt AC 91 ms 106236 KiB
04_max_01.txt AC 138 ms 160024 KiB
04_max_02.txt AC 290 ms 238044 KiB
04_max_03.txt AC 139 ms 160024 KiB
04_max_04.txt AC 215 ms 199064 KiB
04_max_05.txt AC 138 ms 160060 KiB
04_max_06.txt AC 274 ms 229828 KiB
05_n_large_01.txt AC 289 ms 237464 KiB
05_n_large_02.txt AC 288 ms 236948 KiB
05_n_large_03.txt AC 287 ms 236084 KiB
05_n_large_04.txt AC 287 ms 235560 KiB
05_n_large_05.txt AC 289 ms 237496 KiB