結果
問題 | No.2772 Appearing Even Times |
ユーザー | GOTKAKO |
提出日時 | 2024-05-31 21:57:05 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 144 ms / 4,000 ms |
コード長 | 2,386 bytes |
コンパイル時間 | 2,213 ms |
コンパイル使用メモリ | 204,400 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-20 23:18:57 |
合計ジャッジ時間 | 4,710 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; long long mod = 998244353; //入力が必ずmod未満の時に使う. struct mint{ long long v = 0; mint(){} mint(int a){v = a;} mint(long long a){v = a;} mint(unsigned long long a){v = a;} long long val(){return v;} void modu(){v %= mod;} mint repeat2mint(const long long a,long long b){ mint ret = 1,p = a; while(b){ if(b&1) ret *= p; p *= p; b >>= 1; } return ret; }; mint operator+(const mint b){return mint(v)+=b;} mint operator-(const mint b){return mint(v)-=b;} mint operator*(const mint b){return mint(v)*=b;} mint operator/(const mint b){return mint(v)/=b;} mint operator+=(const mint b){ v += b.v; if(v >= mod) v -= mod; return *this; } mint operator-=(const mint b){ v -= b.v; if(v < 0) v += mod; return *this; } mint operator*=(const mint b){v = v*b.v%mod; return *this;} mint operator/=(mint b){ if(b == 0) assert(false); int left = mod-2; while(left){if(left&1) *this *= b; b *= b; left >>= 1;} return *this; } mint operator++(int){*this += 1; return *this;} mint operator--(int){*this -= 1; return *this;} bool operator==(const mint b){return v == b.v;} bool operator!=(const mint b){return v != b.v;} bool operator>(const mint b){return v > b.v;} bool operator>=(const mint b){return v >= b.v;} bool operator<(const mint b){return v < b.v;} bool operator<=(const mint b){return v <= b.v;} mint pow(const long long x){return repeat2mint(v,x);} mint inv(){return mint(1)/v;} }; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; int N = s.size(); int S = 0; vector<mint> dp(1<<10); for(int i=0; i<N; i++){ int C = s.at(i)-'0'; vector<mint> next(1<<10); for(int k=0; k<(1<<10); k++){ if(dp.at(k) == 0) continue; for(int l=0; l<10; l++) next.at(k^(1<<l)) += dp.at(k); } if(i) for(int k=1; k<10; k++) next.at(1<<k)++; for(int k=0; k<C; k++){ if(i == 0 && k == 0) continue; next.at(S^(1<<k))++; } S ^= (1<<C); swap(next,dp); } if(S == 0) dp.at(0)++; cout << dp.at(0).v << endl; }