CF1336C.Kaavi and Magic Spell

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Kaavi, the mysterious fortune teller, deeply believes that one's fate is inevitable and unavoidable. Of course, she makes her living by predicting others' future. While doing divination, Kaavi believes that magic spells can provide great power for her to see the future.

Kaavi has a string TT of length mm and all the strings with the prefix TT are magic spells. Kaavi also has a string SS of length nn and an empty string AA .

During the divination, Kaavi needs to perform a sequence of operations. There are two different operations:

  • Delete the first character of SS and add it at the front of AA .
  • Delete the first character of SS and add it at the back of AA .

Kaavi can perform no more than nn operations. To finish the divination, she wants to know the number of different operation sequences to make AA a magic spell (i.e. with the prefix TT ). As her assistant, can you help her? The answer might be huge, so Kaavi only needs to know the answer modulo 998244353998\,244\,353 .

Two operation sequences are considered different if they are different in length or there exists an ii that their ii -th operation is different.

A substring is a contiguous sequence of characters within a string. A prefix of a string SS is a substring of SS that occurs at the beginning of SS .

输入格式

The first line contains a string SS of length nn ( 1n30001 \leq n \leq 3000 ).

The second line contains a string TT of length mm ( 1mn1 \leq m \leq n ).

Both strings contain only lowercase Latin letters.

输出格式

The output contains only one integer — the answer modulo 998244353998\,244\,353 .

输入输出样例

  • 输入#1

    abab
    ba

    输出#1

    12
  • 输入#2

    defineintlonglong
    signedmain

    输出#2

    0
  • 输入#3

    rotator
    rotator

    输出#3

    4
  • 输入#4

    cacdcdbbbb
    bdcaccdbbb

    输出#4

    24

说明/提示

The first test:

The red ones are the magic spells. In the first operation, Kaavi can either add the first character "a" at the front or the back of AA , although the results are the same, they are considered as different operations. So the answer is 6×2=126\times2=12 .

首页