結果
問題 | No.2060 AND Sequence |
ユーザー | auaua |
提出日時 | 2022-08-26 22:37:03 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 766 ms / 2,000 ms |
コード長 | 2,373 bytes |
コンパイル時間 | 1,649 ms |
コンパイル使用メモリ | 171,316 KB |
実行使用メモリ | 62,720 KB |
最終ジャッジ日時 | 2024-04-22 00:42:32 |
合計ジャッジ時間 | 23,559 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
8,264 KB |
testcase_01 | AC | 39 ms
8,192 KB |
testcase_02 | AC | 389 ms
35,200 KB |
testcase_03 | AC | 41 ms
8,136 KB |
testcase_04 | AC | 41 ms
8,260 KB |
testcase_05 | AC | 41 ms
8,320 KB |
testcase_06 | AC | 40 ms
8,136 KB |
testcase_07 | AC | 42 ms
8,320 KB |
testcase_08 | AC | 42 ms
8,264 KB |
testcase_09 | AC | 41 ms
8,320 KB |
testcase_10 | AC | 40 ms
8,140 KB |
testcase_11 | AC | 42 ms
8,136 KB |
testcase_12 | AC | 42 ms
8,268 KB |
testcase_13 | AC | 42 ms
8,264 KB |
testcase_14 | AC | 223 ms
22,144 KB |
testcase_15 | AC | 299 ms
27,592 KB |
testcase_16 | AC | 447 ms
38,476 KB |
testcase_17 | AC | 290 ms
27,080 KB |
testcase_18 | AC | 180 ms
18,688 KB |
testcase_19 | AC | 254 ms
24,192 KB |
testcase_20 | AC | 534 ms
46,080 KB |
testcase_21 | AC | 461 ms
40,136 KB |
testcase_22 | AC | 119 ms
13,900 KB |
testcase_23 | AC | 580 ms
48,844 KB |
testcase_24 | AC | 757 ms
61,388 KB |
testcase_25 | AC | 746 ms
62,080 KB |
testcase_26 | AC | 756 ms
62,592 KB |
testcase_27 | AC | 719 ms
60,360 KB |
testcase_28 | AC | 740 ms
62,080 KB |
testcase_29 | AC | 714 ms
60,672 KB |
testcase_30 | AC | 751 ms
62,220 KB |
testcase_31 | AC | 709 ms
60,672 KB |
testcase_32 | AC | 723 ms
61,440 KB |
testcase_33 | AC | 721 ms
60,836 KB |
testcase_34 | AC | 744 ms
62,012 KB |
testcase_35 | AC | 731 ms
62,028 KB |
testcase_36 | AC | 733 ms
61,696 KB |
testcase_37 | AC | 735 ms
60,124 KB |
testcase_38 | AC | 766 ms
62,176 KB |
testcase_39 | AC | 743 ms
60,696 KB |
testcase_40 | AC | 739 ms
61,124 KB |
testcase_41 | AC | 751 ms
62,012 KB |
testcase_42 | AC | 732 ms
61,656 KB |
testcase_43 | AC | 711 ms
60,868 KB |
testcase_44 | AC | 733 ms
62,720 KB |
testcase_45 | AC | 734 ms
62,716 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; #include <unordered_set> #include <random> //#define int long long #define REP(i,m,n) for(int i=(m);i<(n);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define all(a) a.begin(),a.end() #define rall(c) (c).rbegin(),(c).rend() #define mp make_pair #define endl '\n' //#define vec vector<ll> //#define mat vector<vector<ll> > #define fi first #define se second #define double long double typedef long long ll; typedef unsigned long long ull; typedef pair<ll,ll> pll; //typedef long double ld; typedef complex<double> Complex; const ll INF=1e9+7; const ll MOD=998244353; const ll inf=INF*INF; const ll mod=MOD; const ll inv2=499122177; const ll MAX=200010; const double PI=acos(-1.0); typedef vector<vector<ll> > mat; typedef vector<ll> vec; ll dx[]={0,1,0,-1,-1,-1,1,1}; ll dy[]={1,0,-1,0,-1,1,-1,1}; string u="RDLU"; //Combination long long extGCD(long long a,long long mod,long long &x,long long &y){ if(mod==0){ x=1; y=0; return a; } long long d=extGCD(mod,a%mod,y,x); y-=(a/mod)*x; return d; } long long invmod(long long a,long long mod){ long long x,y; extGCD(a,mod,x,y); x%=mod; if(x<0)x+=mod; return x; } ll fac[MAX],finv[MAX],inv[MAX]; void combinit(){ fac[0]=fac[1]=1; finv[0]=finv[1]=1; inv[1]=1; REP(i,2,MAX){ fac[i]=fac[i-1]*i%mod; inv[i]=invmod(i,mod); finv[i]=finv[i-1]*inv[i]%mod; } } ll comb(ll n,ll k){ if(n<k)return 0; if(n<0||k<0)return 0; return fac[n]*(finv[k]*finv[n-k]%mod)%mod; } void solve(){ combinit(); ll N,M;cin>>N>>M; //M以下で k bit のものはいくつあるか vector<ll>cnt(31); ll now=0; for(int i=29;i>=0;i--){ if((1<<i)&M){ rep(j,i+1){ cnt[now+j]+=comb(i,j); cnt[now+j]%=mod; } now++; } } cnt[now]++; vector<vector<ll> >dp(N,vector<ll>(31)); rep(i,31)dp[0][i]=cnt[i]; rep(i,N-1){ rep(j,31){ rep(k,j+1){ dp[i+1][k]=(dp[i+1][k]+dp[i][j]*comb(j,k)%mod)%mod; } } } ll ans=0; rep(i,31){ ans+=dp[N-1][i]; ans%=mod; } if(ans<0)ans+=mod; cout<<ans<<endl; } signed main(){ //cin.tie(0); //ios::sync_with_stdio(false); solve(); }