CF1239A Ivan the Fool and the Probability Theory

思路:

可以转化为“strip”(http://tech-queries.blogspot.com/2011/07/fit-12-dominos-in-2n-strip.html)问题。参考了https://www.cnblogs.com/lyttt/p/11723194.html。

实现:

 1 #include 
 2 using namespace std;
 3 const int MOD = 1e9 + 7;
 4 int a[100005];
 5 int main()
 6 {
 7     a[1] = 1; a[2] = 2;
 8     for (int i = 3; i <= 100000; i++) a[i] = (a[i - 1] + a[i - 2]) % MOD;
 9     int n, m;
10     while (cin >> n >> m)
11     {
12         cout << (a[n] + a[m] - 1) % MOD * 2 % MOD << endl;
13     }
14     return 0;
15 }

你可能感兴趣的:(CF1239A Ivan the Fool and the Probability Theory)