結果
問題 | No.1757 Many Many Cards |
ユーザー | beet |
提出日時 | 2021-11-20 15:14:30 |
言語 | C++23(draft) (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 81 ms / 2,000 ms |
コード長 | 3,369 bytes |
コンパイル時間 | 3,020 ms |
コンパイル使用メモリ | 249,952 KB |
実行使用メモリ | 14,896 KB |
最終ジャッジ日時 | 2023-09-02 09:39:29 |
合計ジャッジ時間 | 6,780 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 20 ms
14,764 KB |
testcase_01 | AC | 20 ms
14,760 KB |
testcase_02 | AC | 21 ms
14,552 KB |
testcase_03 | AC | 20 ms
14,832 KB |
testcase_04 | AC | 20 ms
14,700 KB |
testcase_05 | AC | 20 ms
14,828 KB |
testcase_06 | AC | 20 ms
14,548 KB |
testcase_07 | AC | 21 ms
14,680 KB |
testcase_08 | AC | 20 ms
14,564 KB |
testcase_09 | AC | 20 ms
14,832 KB |
testcase_10 | AC | 20 ms
14,800 KB |
testcase_11 | AC | 21 ms
14,612 KB |
testcase_12 | AC | 20 ms
14,680 KB |
testcase_13 | AC | 20 ms
14,680 KB |
testcase_14 | AC | 20 ms
14,836 KB |
testcase_15 | AC | 20 ms
14,664 KB |
testcase_16 | AC | 20 ms
14,552 KB |
testcase_17 | AC | 20 ms
14,720 KB |
testcase_18 | AC | 19 ms
14,668 KB |
testcase_19 | AC | 19 ms
14,728 KB |
testcase_20 | AC | 20 ms
14,812 KB |
testcase_21 | AC | 30 ms
14,780 KB |
testcase_22 | AC | 59 ms
14,804 KB |
testcase_23 | AC | 62 ms
14,768 KB |
testcase_24 | AC | 44 ms
14,560 KB |
testcase_25 | AC | 54 ms
14,720 KB |
testcase_26 | AC | 20 ms
14,796 KB |
testcase_27 | AC | 34 ms
14,616 KB |
testcase_28 | AC | 66 ms
14,552 KB |
testcase_29 | AC | 54 ms
14,896 KB |
testcase_30 | AC | 22 ms
14,552 KB |
testcase_31 | AC | 20 ms
14,672 KB |
testcase_32 | AC | 38 ms
14,620 KB |
testcase_33 | AC | 28 ms
14,836 KB |
testcase_34 | AC | 28 ms
14,760 KB |
testcase_35 | AC | 31 ms
14,776 KB |
testcase_36 | AC | 80 ms
14,716 KB |
testcase_37 | AC | 81 ms
14,852 KB |
testcase_38 | AC | 19 ms
14,560 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using Int = long long; const char newl = '\n'; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);} template<typename T=int> vector<T> read(size_t n){ vector<T> ts(n); for(size_t i=0;i<n;i++) cin>>ts[i]; return ts; } template<typename T, T MOD = 1000000007> struct Mint{ inline static constexpr T mod = MOD; T v; Mint():v(0){} Mint(signed v):v(v){} Mint(long long t){v=t%MOD;if(v<0) v+=MOD;} Mint pow(long long k){ Mint res(1),tmp(v); while(k){ if(k&1) res*=tmp; tmp*=tmp; k>>=1; } return res; } static Mint add_identity(){return Mint(0);} static Mint mul_identity(){return Mint(1);} Mint inv(){return pow(MOD-2);} Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;} Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;} Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;} Mint& operator/=(Mint a){return (*this)*=a.inv();} Mint operator+(Mint a) const{return Mint(v)+=a;} Mint operator-(Mint a) const{return Mint(v)-=a;} Mint operator*(Mint a) const{return Mint(v)*=a;} Mint operator/(Mint a) const{return Mint(v)/=a;} Mint operator+() const{return *this;} Mint operator-() const{return v?Mint(MOD-v):Mint(v);} bool operator==(const Mint a)const{return v==a.v;} bool operator!=(const Mint a)const{return v!=a.v;} static Mint comb(long long n,int k){ Mint num(1),dom(1); for(int i=0;i<k;i++){ num*=Mint(n-i); dom*=Mint(i+1); } return num/dom; } }; template<typename T, T MOD> ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;} template<typename M_> class Enumeration{ using M = M_; protected: inline static vector<M> fact,finv,invs; public: static void init(int n){ n=min<decltype(M::mod)>(n,M::mod-1); int m=fact.size(); if(n<m) return; fact.resize(n+1,1); finv.resize(n+1,1); invs.resize(n+1,1); if(m==0) m=1; for(int i=m;i<=n;i++) fact[i]=fact[i-1]*M(i); finv[n]=M(1)/fact[n]; for(int i=n;i>=m;i--) finv[i-1]=finv[i]*M(i); for(int i=m;i<=n;i++) invs[i]=finv[i]*fact[i-1]; } static M Fact(int n){ init(n); return fact[n]; } static M Finv(int n){ init(n); return finv[n]; } static M Invs(int n){ init(n); return invs[n]; } static M C(int n,int k){ if(n<k or k<0) return M(0); init(n); return fact[n]*finv[n-k]*finv[k]; } static M P(int n,int k){ if(n<k or k<0) return M(0); init(n); return fact[n]*finv[n-k]; } // put n identical balls into k distinct boxes static M H(int n,int k){ if(n<0 or k<0) return M(0); if(!n and !k) return M(1); init(n+k); return C(n+k-1,n); } }; //INSERT ABOVE HERE signed main(){ cin.tie(0); ios::sync_with_stdio(0); using M = Mint<int, 998244353>; using E = Enumeration<M>; E::init(1e6+10); int n,m; cin>>n>>m; M ans=M(m)*M(m).pow(n+n); for(int i=1;i<=m;i++){ int x=i-1; int y=n-x; if(y<0) continue; M res=E::C(m,i)*E::C(n,x); if(i>=2) res*=M(i).pow(i-2)*E::Fact(x)*M(2).pow(x); res*=M(m-i).pow(y+y); ans-=res; } cout<<ans<<newl; return 0; }