結果

問題 No.1762 🐙🐄🌲
ユーザー leukocyteleukocyte
提出日時 2022-07-02 14:53:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,072 bytes
コンパイル時間 1,633 ms
コンパイル使用メモリ 167,168 KB
実行使用メモリ 7,776 KB
最終ジャッジ日時 2023-08-18 05:52:50
合計ジャッジ時間 3,740 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,588 KB
testcase_01 AC 2 ms
5,656 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,692 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,384 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 WA -
testcase_31 AC 2 ms
4,384 KB
testcase_32 WA -
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 6 ms
6,748 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 WA -
testcase_39 AC 2 ms
4,380 KB
testcase_40 WA -
testcase_41 AC 1 ms
4,380 KB
testcase_42 WA -
testcase_43 AC 1 ms
4,376 KB
testcase_44 WA -
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 8 ms
7,268 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 WA -
testcase_49 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=5e5;
const int mod=998244353;
using arr=int[N+5];
arr fac,ifac;
int ksm(ll x,int tp,int s=1){
	for(;tp;x=x*x%mod,tp>>=1) if(tp&1) s=x*s%mod;
	return s;
}
void prep(int n){
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=ksm(fac[n],mod-2);
	for(int i=n;i;i--) ifac[i-1]=1ll*ifac[i]*i%mod;
}
int C(int n,int m){ return n<0||m<0||n<m?0:1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod; }
int inv(int n){ return 1ll*ifac[n]*fac[n-1]%mod; }
int n,p,m,r;
arr f;
int ans;
int main(){
	scanf("%d %d",&n,&p);
	m=(3*n+1)/4; r=n-m-1-7*p;
	if(n%4!=1||r<0){
		puts("0"); return 0;
	}
	if(n==1){
		puts("1"); return 0;
	}
	prep(n);
	ans=1ll*C(n,m)*C(m,p)%mod*fac[m-1]%mod*fac[n-m-1]%mod;
	ans=ksm(ifac[3],n-m,ans);
	ans=ksm(ifac[7],p,ans);
	f[0]=1;
	for(int i=1;i<=r;i++){
		ll s=0;
		for(int j=1;j<7&&j<=i;j++)
			s+=1ll*ifac[j-1]*f[i-j];
		s=s%mod*(m+1)%mod*inv(i)%mod;
		for(int j=1;j<7&&j<=i;j++)
			s-=1ll*ifac[j]*f[i-j];
		f[i]=s%mod;
	}
	printf("%lld\n",1ll*ans*(f[r]+mod)%mod);
	return 0;
}
0