結果
問題 |
No.2772 Appearing Even Times
|
ユーザー |
![]() |
提出日時 | 2024-05-31 22:14:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,186 ms / 4,000 ms |
コード長 | 797 bytes |
コンパイル時間 | 4,449 ms |
コンパイル使用メモリ | 257,128 KB |
最終ジャッジ日時 | 2025-02-21 18:01:56 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 1000000000000000001 int main(){ string N; cin>>N; vector dp(2,vector(2,vector<mint>(1<<10,0))); dp[0][0][0] = 1; rep(i,N.size()){ vector ndp(2,vector(2,vector<mint>(1<<10,0))); rep(j,2){ rep(k,2){ rep(l,1<<10){ rep(m,10){ int nj = j,nk = k,nl = l; if(m!=0)nk = 1; if(nk)nl ^= 1<<m; if(j==0 && N[i]-'0' < m)continue; if(N[i]-'0'>m)nj = 1; ndp[nj][nk][nl] += dp[j][k][l]; } } } } swap(dp,ndp); } mint ans = 0; ans += dp[0][1][0] + dp[1][1][0]; cout<<ans.val()<<endl; return 0; }