結果
問題 | No.2060 AND Sequence |
ユーザー | dyktr_06 |
提出日時 | 2022-08-26 22:27:55 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 572 ms / 2,000 ms |
コード長 | 3,952 bytes |
コンパイル時間 | 1,690 ms |
コンパイル使用メモリ | 170,484 KB |
実行使用メモリ | 55,040 KB |
最終ジャッジ日時 | 2024-10-13 23:06:04 |
合計ジャッジ時間 | 18,061 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 286 ms
29,312 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 3 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 2 ms
5,248 KB |
testcase_09 | AC | 3 ms
5,248 KB |
testcase_10 | AC | 2 ms
5,248 KB |
testcase_11 | AC | 2 ms
5,248 KB |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | AC | 2 ms
5,248 KB |
testcase_14 | AC | 149 ms
16,768 KB |
testcase_15 | AC | 206 ms
21,888 KB |
testcase_16 | AC | 315 ms
32,256 KB |
testcase_17 | AC | 201 ms
21,504 KB |
testcase_18 | AC | 112 ms
13,312 KB |
testcase_19 | AC | 171 ms
18,688 KB |
testcase_20 | AC | 397 ms
39,424 KB |
testcase_21 | AC | 336 ms
33,664 KB |
testcase_22 | AC | 65 ms
8,960 KB |
testcase_23 | AC | 426 ms
41,856 KB |
testcase_24 | AC | 557 ms
53,760 KB |
testcase_25 | AC | 566 ms
54,528 KB |
testcase_26 | AC | 572 ms
54,784 KB |
testcase_27 | AC | 549 ms
52,736 KB |
testcase_28 | AC | 566 ms
54,272 KB |
testcase_29 | AC | 549 ms
52,992 KB |
testcase_30 | AC | 568 ms
54,528 KB |
testcase_31 | AC | 552 ms
53,248 KB |
testcase_32 | AC | 558 ms
53,888 KB |
testcase_33 | AC | 550 ms
53,376 KB |
testcase_34 | AC | 563 ms
54,400 KB |
testcase_35 | AC | 563 ms
54,272 KB |
testcase_36 | AC | 560 ms
54,016 KB |
testcase_37 | AC | 545 ms
52,608 KB |
testcase_38 | AC | 566 ms
54,528 KB |
testcase_39 | AC | 549 ms
53,376 KB |
testcase_40 | AC | 552 ms
53,248 KB |
testcase_41 | AC | 566 ms
54,400 KB |
testcase_42 | AC | 561 ms
54,016 KB |
testcase_43 | AC | 553 ms
53,248 KB |
testcase_44 | AC | 572 ms
55,040 KB |
testcase_45 | AC | 570 ms
54,912 KB |
コンパイルメッセージ
main.cpp: In function 'void in(T& ...)': main.cpp:28:55: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 28 | template<class... T> void in(T&... a){ (cin >> ... >> a); } | ^ main.cpp: In function 'void out(const T&, const Ts& ...)': main.cpp:30:112: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 30 | template<class T, class... Ts> void out(const T& a, const Ts&... b){ cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; } | ^
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (int)(n); ++i) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; --i) #define ALL(a) a.begin(), a.end() #define Sort(a) sort(a.begin(), a.end()) #define RSort(a) sort(a.rbegin(), a.rend()) typedef long long int ll; typedef long double ld; typedef vector<int> vi; typedef vector<long long> vll; typedef vector<char> vc; typedef vector<string> vst; typedef vector<double> vd; typedef pair<long long, long long> P; const long long INF = 0x1fffffffffffffff; const long long MOD = 998244353; const long double PI = acos(-1); template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template<class T, class U> inline T vin(T& vec, U n) { vec.resize(n); for(int i = 0; i < (int) n; ++i) cin >> vec[i]; return vec; } template<class T> inline void vout(T vec, string s = "\n"){ for(auto x : vec) cout << x << s; } template<class... T> void in(T&... a){ (cin >> ... >> a); } void out(){ cout << '\n'; } template<class T, class... Ts> void out(const T& a, const Ts&... b){ cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; } template<class T, class U> void inGraph(vector<vector<T>>& G, U n, U m, bool directed = false){ G.resize(n); for(int i = 0; i < m; i++){ int a, b; cin >> a >> b; a--, b--; G[a].push_back(b); if(!directed) G[b].push_back(a); } } struct Combination{ vector<long long> memo; vector<long long> memoinv; long long mod; Combination(int N, long long m) : memo(N+1), memoinv(N+1){ mod = m; memo[0] = 1; for(int i = 1; i <= N; i++){ memo[i] = memo[i-1] * i; memo[i] %= mod; } memoinv[0] = inv(1LL, mod); for(int i = 1; i <= N; i++){ memoinv[i] = inv(1LL * memo[i], mod); memoinv[i] %= mod; } } long long inv(long long a, long long m){ long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } long long fact(long long n){ return memo[n]; } long long factinv(long long n){ return memoinv[n]; } long long ncr(long long n, long long r){ if(n < r || r < 0) return 0; return (memo[n] * memoinv[r] % mod) * memoinv[n - r] % mod; } long long npr(long long n, long long r){ if(n < r || r < 0) return 0; return (memo[n] % mod) * memoinv[n - r] % mod; } }; ll n, m; ll dp[202020][33]; ll dp2[33][2][33]; void input(){ in(n, m); } void solve(){ dp2[0][1][0] = 1; ll mx = 0; for(ll i = 0; 1 << i <= m; i++){ chmax(mx, i); } for(int i = 0; i <= mx; i++){ for(int k = 0; k <= 30; k++){ for(int l = 0; l <= 1; l++){ int cnt = k + l; dp2[i+1][0][cnt] += dp2[i][0][k]; } for(int l = 0; l <= ((m >> (mx - i)) & 1); l++){ int cnt = k + l; int b = 0; if(l == ((m >> (mx - i)) & 1)) b = 1; dp2[i+1][b][cnt] += dp2[i][1][k]; } } } Combination C(33, MOD); for(int j = 0; j <= 30; j++){ dp[0][j] = dp2[mx + 1][0][j] + dp2[mx + 1][1][j]; //out(dp[0][j]); } for(int i = 0; i < n - 1; i++){ for(int j = 0; j <= 30; j++){ for(int k = 0; k <= j; k++){ dp[i + 1][k] += dp[i][j] * C.ncr(j, k); dp[i + 1][k] %= MOD; } } } ll ans = 0; for(int j = 0; j <= 30; j++){ ans += dp[n - 1][j]; ans %= MOD; } out(ans); } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); input(); solve(); }