CF1178C.Tiles

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Bob is decorating his kitchen, more precisely, the floor. He has found a prime candidate for the tiles he will use. They come in a simple form factor — a square tile that is diagonally split into white and black part as depicted in the figure below.

The dimension of this tile is perfect for this kitchen, as he will need exactly w×hw \times h tiles without any scraps. That is, the width of the kitchen is ww tiles, and the height is hh tiles. As each tile can be rotated in one of four ways, he still needs to decide on how exactly he will tile the floor. There is a single aesthetic criterion that he wants to fulfil: two adjacent tiles must not share a colour on the edge — i.e. one of the tiles must have a white colour on the shared border, and the second one must be black.

The picture on the left shows one valid tiling of a 3×23 \times 2 kitchen. The picture on the right shows an invalid arrangement, as the bottom two tiles touch with their white parts.

Find the number of possible tilings. As this number may be large, output its remainder when divided by 998244353998244353 (a prime number).

鲍勃正在装修他的厨房,更准确地说,是在铺设地板。他找到了一种理想的瓷砖。这种瓷砖形状简单——是一块正方形瓷砖,沿对角线分为白色和黑色两部分,如下图所示:

该瓷砖的尺寸恰好适用于这个厨房,因为他将恰好需要 w×hw \times h 块瓷砖,且不产生任何边角料。即:厨房的宽度方向需铺 ww 块瓷砖,高度方向需铺 hh 块瓷砖。由于每块瓷砖均可绕其中心旋转至四种朝向之一,他仍需决定具体的铺贴方式。他唯一追求的美学准则为:任意两个相邻瓷砖在公共边上不能具有相同颜色——即在公共边上,一块瓷砖必须为白色,另一块必须为黑色。


左侧图片展示了一个 3×23 \times 2 厨房的有效铺法;右侧图片则展示了一种无效布局,因为下方两块瓷砖在其公共边上均为白色部分相接。

请计算满足条件的铺法总数。由于该数可能很大,请输出其对 998244353998244353(一个质数)取模的结果。

输入格式

The only line contains two space separated integers ww, hh (1≤w,h≤1 0001 \leq w,h \leq 1\,000) — the width and height of the kitchen, measured in tiles.

唯一的一行包含两个以空格分隔的整数 ww、hh(1≤w,h≤1 0001 \leq w,h \leq 1\,000)——厨房的宽度和高度(以瓷砖为单位)。

输出格式

Output a single integer nn — the remainder of the number of tilings when divided by 998244353998244353.

输出一个整数 nn —— 即铺砌方案总数对 998244353998244353 取模的余数。

输入输出样例

  • 输入#1

    2 2

    输出#1

    16
  • 输入#2

    2 4

    输出#2

    64

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

首页