CF1239A.Ivan the Fool and the Probability Theory
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in that area.
To prove his skills, Ivan decided to demonstrate his friends a concept of random picture. A picture is a field of n rows and m columns, where each cell is either black or white. Ivan calls the picture random if for every cell it has at most one adjacent cell of the same color. Two cells are considered adjacent if they share a side.
Ivan's brothers spent some time trying to explain that it's not how the randomness usually works. Trying to convince Ivan, they want to count the number of different random (according to Ivan) pictures. Two pictures are considered different if at least one cell on those two picture is colored differently. Since the number of such pictures may be quite large, print it modulo 109+7.
最近,愚人伊万决定变得聪明一些,开始学习概率论。他认为自己对该学科的理解已经相当深入,于是表现得仿佛自己已经拿到了该领域的博士学位。
为了证明自己的实力,伊万决定向朋友们展示“随机图片”这一概念。一张图片是一个由 n 行和 m 列组成的方格阵列,其中每个格子非黑即白。伊万称一张图片是“随机的”,当且仅当对每个格子而言,与其相邻(即共享一条边)且颜色相同的格子至多只有一个。
伊万的兄弟们花了一些时间试图解释:这并非通常意义上“随机”的含义。为了说服伊万,他们希望计算出满足伊万定义的“随机图片”的总数。若两张图片至少有一个格子的颜色不同,则认为它们是不同的图片。由于此类图片的总数可能非常大,请输出结果对 109+7 取模后的值。
输入格式
The only line contains two integers n and m (1≤n,m≤100000), the number of rows and the number of columns of the field.
唯一的一行包含两个整数 n 和 m(1≤n,m≤100000),分别表示场地的行数和列数。
输出格式
Print one integer, the number of random pictures modulo 109+7.
输出一个整数,表示随机图片的数量对 109+7 取模的结果。
输入输出样例
输入#1
2 3
输出#1
8
说明/提示
The picture below shows all possible random pictures of size 2 by 3.

下图展示了所有可能的 2 行 3 列随机图片。

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