結果
問題 |
No.3053 $((0 \And 1)\mathop{|}2)\oplus 3$
|
ユーザー |
|
提出日時 | 2025-01-18 16:29:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 962 bytes |
コンパイル時間 | 583 ms |
コンパイル使用メモリ | 73,652 KB |
実行使用メモリ | 5,612 KB |
最終ジャッジ日時 | 2025-01-18 16:29:44 |
合計ジャッジ時間 | 6,918 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 RE * 18 |
ソースコード
// TLE #include <array> #include <iostream> #include <vector> #include <atcoder/modint> using mint = atcoder::modint998244353; mint naive(std::string n_str) { int l = n_str.size(); assert(l <= 20); int n = 0; for (char c : n_str) { n = n * 2 + (c - '0'); } mint ans = 0; for (int i = 0; i < l; ++i) { std::array<mint, 2> pd{}; pd[0] = 1; for (int v = 1; v <= n; ++v) { int b = (v >> i) & 1; std::array<mint, 2> dp{}; for (int x = 0; x < 2; ++x) { dp[x | b] += pd[x]; dp[x & b] += pd[x]; dp[x ^ b] += pd[x]; } pd = std::move(dp); } ans += (long long) pd[1].val() << i; } return ans; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::string n_str; std::cin >> n_str; std::cout << naive(n_str).val() << std::endl; }