結果

問題 No.3242 Count 8 Included Numbers (Hard)
ユーザー timi
提出日時 2025-08-22 22:03:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 927 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 82,900 KB
実行使用メモリ 78,304 KB
最終ジャッジ日時 2025-08-22 22:03:46
合計ジャッジ時間 6,260 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4 WA * 1
other AC * 11 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()


mod=998244353
for i in range(len(S)):
  s=int(S[i])
  if i==0:
    dp=[[0,0] for i in range(2)]
    if s==7:
      dp[1][0]=s-1 
      dp[0][0]=1 
    elif s==8:
      dp[1][0]=s-1 
      dp[0][1]=1
    else:
      dp[1][0]=s-2
      dp[1][1]=1 
      dp[0][0]=1
  else:
    ndp=[[0,0] for i in range(2)]
    for i in range(s+1):
      if i!=s and i==8:
        ndp[1][1]+=dp[0][0]
        ndp[1][1]+=dp[0][1]
      elif i==s and i==8:
        ndp[0][1]+=dp[0][0]
        ndp[0][1]+=dp[0][1]
      elif i!=s and i!=8:
        ndp[1][0]+=dp[0][0]
        ndp[1][1]+=dp[0][1]
      elif i==s and i!=8:
        ndp[0][0]+=dp[0][0]
        ndp[0][1]+=dp[0][1]
        
    ndp[1][0]+=dp[1][0]*9
    ndp[1][1]+=dp[1][0]
    ndp[1][1]+=dp[1][1]*10
    
      
    ndp[1][1]+=1
    ndp[1][0]+=8 
    dp=ndp 
    dp[0][0]%=mod
    dp[0][1]%=mod
    dp[1][1]%=mod
    dp[1][0]%=mod
ans=dp[0][1]+dp[1][1]
ans%=mod 
print(ans)
0