CF2204G.Grid Path

省选/NOI-

通过率:0%

时间限制:3.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

You are given a grid with nn rows (numbered from 11 to nn from top to bottom) and mm columns (numbered from 11 to mm from left to right). You are controlling a chip that is initially in the cell (1,1)(1, 1). In one move, the chip can move left, right, or down (if the current cell is (x,y)(x, y), it can go to (x,y−1)(x, y - 1), (x,y+1)(x, y + 1), or (x+1,y)(x + 1, y)). The chip cannot leave the grid.

You can make any number of moves (possibly zero). Let's define the path of a chip as the set of cells it visits at least once. Note that the order of visited cells doesn't matter.

Your task is to calculate the number of possible paths. Since the answer might be large, print it modulo modmod.

给你一个 nn 行(从上到下编号为 11 到 nn)和 mm 列(从左到右编号为 11 到 mm)的网格。你控制一个芯片,它初始位于单元格 (1,1)(1, 1)。在一次移动中,芯片可以向左、向右或向下移动(若当前单元格为 (x,y)(x, y),则它可以移动到 (x,y−1)(x, y - 1)、(x,y+1)(x, y + 1) 或 (x+1,y)(x + 1, y))。芯片不能移出网格边界。

你可以进行任意次数(包括零次)的移动。我们定义芯片的路径为它至少访问过一次的所有单元格构成的集合(注意:访问顺序无关紧要)。

你的任务是计算可能的路径总数。由于答案可能很大,请对 modmod 取模后输出。

输入格式

The only line contains three integers nn, mm, and modmod (1≤n≤1081 \le n \le 10^8; 1≤m≤1501 \le m \le 150; 2≤mod≤1092 \le mod \le 10^9).

唯一一行包含三个整数 nn、mm 和 modmod(1≤n≤1081 \le n \le 10^8;1≤m≤1501 \le m \le 150;2≤mod≤1092 \le mod \le 10^9)。

输出格式

Print a single integer — the number of possible paths, taken modulo modmod.

输出一个整数——可能的路径数量对 modmod 取模的结果。

输入输出样例

  • 输入#1

    2 2 100

    输出#1

    7
  • 输入#2

    1 5 777

    输出#2

    5
  • 输入#3

    5 3 998244353

    输出#3

    1695
  • 输入#4

    100000000 150 1000000000

    输出#4

    89058885

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

首页