CF1580F.Problems for Codeforces

NOI/NOI+/CTSC

通过率:0%

时间限制:8.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

XYMXYM and CQXYM will prepare nn problems for Codeforces. The difficulty of the problem ii will be an integer aia_i, where ai≥0a_i \geq 0. The difficulty of the problems must satisfy ai+ai+1<ma_i+a_{i+1} \lt m (1≤i<n1 \leq i \lt n), and a1+an<ma_1+a_n \lt m, where mm is a fixed integer. XYMXYM wants to know how many plans of the difficulty of the problems there are modulo 998 244 353998\,244\,353.

Two plans of difficulty aa and bb are different only if there is an integer ii (1≤i≤n1 \leq i \leq n) satisfying ai≠bia_i \neq b_i.

XYMXYM 和 CQXYM 将为 Codeforces 准备 nn 道题目。第 ii 道题的难度为一个整数 aia_i,其中 ai≥0a_i \geq 0。题目的难度需满足约束条件:对所有 1≤i<n1 \leq i < n,有 ai+ai+1<ma_i + a_{i+1} < m,且 a1+an<ma_1 + a_n < m,其中 mm 是一个给定的固定整数。XYMXYM 想知道满足上述条件的难度设定方案总数,答案对 998 244 353998\,244\,353 取模。

若存在某个整数 ii(1≤i≤n1 \leq i \leq n)使得 ai≠bia_i \neq b_i,则称两个难度序列 aa 和 bb 是不同的。

输入格式

A single line contains two integers nn and mm (2≤n≤50 0002 \leq n \leq 50\,000, 1≤m≤1091 \leq m \leq 10^9).

一行包含两个整数 nn 和 mm(2≤n≤50 0002 \leq n \leq 50\,000,1≤m≤1091 \leq m \leq 10^9)。

输出格式

Print a single integer — the number of different plans.

输出一个整数——不同方案的数量。

输入输出样例

  • 输入#1

    3 2

    输出#1

    4
  • 输入#2

    5 9

    输出#2

    8105
  • 输入#3

    21038 3942834

    输出#3

    338529212

说明/提示

In the first test case, the valid aa are: [0,0,0][0,0,0], [0,0,1][0,0,1], [0,1,0][0,1,0], [1,0,0][1,0,0].

[1,0,1][1,0,1] is invalid since a1+an≥ma_1+a_n \geq m.

在第一个测试用例中,合法的 aa 有:[0,0,0][0,0,0]、[0,0,1][0,0,1]、[0,1,0][0,1,0]、[1,0,0][1,0,0]。

[1,0,1][1,0,1] 不合法,因为 a1+an≥ma_1+a_n \geq m。

输入解题思路,AI测评打分。不知道怎么写?

首页