結果

問題 No.2772 Appearing Even Times
ユーザー nononnonon
提出日時 2024-05-31 22:35:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,289 ms / 4,000 ms
コード長 730 bytes
コンパイル時間 2,290 ms
コンパイル使用メモリ 204,436 KB
実行使用メモリ 165,132 KB
最終ジャッジ日時 2024-05-31 22:36:10
合計ジャッジ時間 17,370 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
164,912 KB
testcase_01 AC 47 ms
165,132 KB
testcase_02 AC 47 ms
165,132 KB
testcase_03 AC 47 ms
165,044 KB
testcase_04 AC 47 ms
164,964 KB
testcase_05 AC 48 ms
164,984 KB
testcase_06 AC 45 ms
165,060 KB
testcase_07 AC 45 ms
164,980 KB
testcase_08 AC 1,032 ms
165,112 KB
testcase_09 AC 1,289 ms
165,088 KB
testcase_10 AC 45 ms
164,948 KB
testcase_11 AC 46 ms
165,104 KB
testcase_12 AC 1,124 ms
164,980 KB
testcase_13 AC 1,124 ms
164,976 KB
testcase_14 AC 1,139 ms
165,040 KB
testcase_15 AC 1,123 ms
165,064 KB
testcase_16 AC 1,107 ms
165,120 KB
testcase_17 AC 1,125 ms
165,004 KB
testcase_18 AC 1,116 ms
165,028 KB
testcase_19 AC 1,116 ms
165,132 KB
testcase_20 AC 1,106 ms
164,944 KB
testcase_21 AC 1,092 ms
164,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
string S;
int N;
mint dp[10101][1<<10][2][2];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>S;
    N=S.size();
    dp[0][0][0][0]=1;
    for(int i=0;i<N;i++)for(int bit=0;bit<1024;bit++)for(int s=0;s<2;s++)for(int z=0;z<2;z++)for(int j=0;j<10;j++)
    {
        if(!s&&j>S[i]-'0')continue;
        if(!z&&!j)
        {
            dp[i+1][bit][s||j<S[i]-'0'][z]=(bit==0)&&(s||j<S[i]-'0')&&(z==0);
            continue;
        }
        dp[i+1][bit^(1<<j)][s||(j<S[i]-'0')][z||j>0]+=dp[i][bit][s][z];
    }
    mint ans=0;
    for(int s:{0,1})ans+=dp[N][0][s][1];
    cout<<ans.val()<<endl;
}
0