思路:

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

实现:

 #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + ;
int a[];
int main()
{
a[] = ; a[] = ;
for (int i = ; i <= ; i++) a[i] = (a[i - ] + a[i - ]) % MOD;
int n, m;
while (cin >> n >> m)
{
cout << (a[n] + a[m] - ) % MOD * % MOD << endl;
}
return ;
}

CF1239A Ivan the Fool and the Probability Theory的更多相关文章

  1. Codeforces Round #594 (Div. 1) A. Ivan the Fool and the Probability Theory 动态规划

    A. Ivan the Fool and the Probability Theory Recently Ivan the Fool decided to become smarter and stu ...

  2. CF C.Ivan the Fool and the Probability Theory【思维·构造】

    题目传送门 题目大意: 一个$n*m$的网格图,每个格子可以染黑色.白色,问每个格子最多有一个相邻格子颜色相同的涂色方案数$n,m<=1e5$ 分析: 首先,考虑到如果有两个相邻的格子颜色相同, ...

  3. Codeforces 1239A. Ivan the Fool and the Probability Theory

    传送门 注意到连续两个格子如果有相同颜色那么一路过去的都可以确定 比如一开始染了这两个位置: 然后发现后面整片过去都可以确定: 对于横着的情况也是一样,然后就会发现不可能出现横着两个和竖着两个同时都有 ...

  4. Codeforces 1248C Ivan the Fool and the Probability Theory(推公式)

    题意 一个n*m的网格图,每个格子可以染黑色.白色,问你每个格子最多有一个相邻颜色相同的方案数 n,m<=1e5 思路 我们先处理\(1 \times m\)的情况 设\(f[i][j]\)为前 ...

  5. Codeforces Round #594 (Div. 2) - C. Ivan the Fool and the Probability Theory(思维)

    题意:给n*m的网格涂黑白两种颜色,保证每个格子上下左右的四个格子中最多只有一个格子与自己颜色相同,问有多少种涂法?结果$mod1000000007$ 思路:先只考虑一行有多少种涂法 $dp[i][0 ...

  6. Codeforces Round #594 (Div. 1) Ivan the Fool and the Probability Theory

    题意:给你一个NxM的图,让你求有多少符合 “一个格子最多只有一个同颜色邻居”的图? 题解:首先我们可以分析一维,很容易就可以知道这是一个斐波那契计数 因为dp[1][m]可以是dp[1][m-1]添 ...

  7. Codeforces Round #594 (Div. 2) C. Ivan the Fool and the Probability Theory (思维,递推)

    题意:给你一个\(n\)x\(m\)的矩阵,需要在这些矩阵中涂色,每个格子可以涂成黑色或者白色,一个格子四周最多只能有\(2\)个和它颜色相同的,问最多有多少种涂色方案. 题解:首先我们考虑一维的情况 ...

  8. C - Ivan the Fool and the Probability Theory---div2

    题目连接:https://codeforces.com/contest/1248/problem/C 思路: 注意上下两排的关系,如果说上面那一排有两个方格连续,那么他相邻的两排必定和他相反,如果说当 ...

  9. 一起啃PRML - 1.2 Probability Theory 概率论

    一起啃PRML - 1.2 Probability Theory @copyright 转载请注明出处 http://www.cnblogs.com/chxer/ A key concept in t ...

随机推荐

  1. regedit系统注册表,msconfig系统配置

    msconfig msconfig即系统配置实用程序,是Microsoft System Configuration的缩写.是在开始菜单里运行中输入然后确认就可以找到程序开启或者禁用, 可以帮助电脑禁 ...

  2. zabbix的历史数据存储到elasticsearch中

    基本配置项 https://www.jianshu.com/p/bffca8128e8f 官方说这个实验性的功能支持es的版本是5.0.x - > 6.1.x,如果使用早期或更高版本的Elast ...

  3. leetcode解题报告(28):Remove Linked List Elements

    描述 Remove all elements from a linked list of integers that have value val. Example Given: 1 --> 2 ...

  4. 2019软工实践_Alpha(1/6)

    队名:955 组长博客:https://www.cnblogs.com/cclong/p/11841141.html 作业博客:https://edu.cnblogs.com/campus/fzu/S ...

  5. Thingsboard学习之三启动Thingsboard

    关于安装Docker和Docker-Compose,参考<Thingsboard学习之二安装Docker和Docker-Compose> 首先检查一下是否有安装git yum instal ...

  6. GB28181技术基础之1 - SIP协议

    SIP 协议,即 会话初始协议(Session Initiation Protocol),是一个应用层的 点对点协议,用于初始.管理和终止网络中的语音和视频会话,是 GB28181 的核心之一. 按照 ...

  7. 使用Eclipse创建Web项目时WEB-INF下找不到web.xml问题详解

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/yjrguxing/article/deta ...

  8. php递归注意事项

    /* 循环去除字符串左边的0 */ function removeLeftZero($str){ if($str['0'] == '0'){ $str = substr($str, '1'); rem ...

  9. 002 centos7中遇到的问题

    在关机的时候,发现输入密码之后竟然报错了,然后确认普通用户的密码没有问题.下面是处理方式. 一:问题 1.问题 当在终端执行sudo命令时,系统提示“caojun is not in the sudo ...

  10. Centos7 安装 weblogic12.2.1.0.0

    下载地址:地址:http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-main-097127.html 下载最新的we ...