1178C.md (1823B)
1 Source: https://codeforces.com/problemset/problem/1178/C 2 3 C. Tiles 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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. 22 23  24 25 The dimension of this tile is perfect for this kitchen, as he will need exactly $w \times h$ tiles without any scraps. That is, the width of the kitchen is $w$ tiles, and the height is $h$ 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. 26 27  The picture on the left shows one valid tiling of a $3 \times 2$ kitchen. The picture on the right shows an invalid arrangement, as the bottom two tiles touch with their white parts. 28 29 Find the number of possible tilings. As this number may be large, output its remainder when divided by $998244353$ (a prime number). 30 31 Input 32 33 The only line contains two space separated integers $w$, $h$ ($1 \leq w,h \leq 1\,000$) — the width and height of the kitchen, measured in tiles. 34 35 Output 36 37 Output a single integer $n$ — the remainder of the number of tilings when divided by $998244353$. 38 39 Examples 40 41 Input 42 43 ``` 44 2 2 45 ``` 46 47 Output 48 49 ``` 50 16 51 ``` 52 53 Input 54 55 ``` 56 2 4 57 ``` 58 59 Output 60 61 ``` 62 64 63 ```