結果
| 問題 |
No.2772 Appearing Even Times
|
| コンテスト | |
| ユーザー |
nonon
|
| 提出日時 | 2024-05-31 22:35:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,170 ms / 4,000 ms |
| コード長 | 730 bytes |
| コンパイル時間 | 2,143 ms |
| コンパイル使用メモリ | 196,196 KB |
| 最終ジャッジ日時 | 2025-02-21 18:11:38 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
#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;
}
nonon