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。
实现:
#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的更多相关文章
- 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 ...
- CF C.Ivan the Fool and the Probability Theory【思维·构造】
题目传送门 题目大意: 一个$n*m$的网格图,每个格子可以染黑色.白色,问每个格子最多有一个相邻格子颜色相同的涂色方案数$n,m<=1e5$ 分析: 首先,考虑到如果有两个相邻的格子颜色相同, ...
- Codeforces 1239A. Ivan the Fool and the Probability Theory
传送门 注意到连续两个格子如果有相同颜色那么一路过去的都可以确定 比如一开始染了这两个位置: 然后发现后面整片过去都可以确定: 对于横着的情况也是一样,然后就会发现不可能出现横着两个和竖着两个同时都有 ...
- Codeforces 1248C Ivan the Fool and the Probability Theory(推公式)
题意 一个n*m的网格图,每个格子可以染黑色.白色,问你每个格子最多有一个相邻颜色相同的方案数 n,m<=1e5 思路 我们先处理\(1 \times m\)的情况 设\(f[i][j]\)为前 ...
- Codeforces Round #594 (Div. 2) - C. Ivan the Fool and the Probability Theory(思维)
题意:给n*m的网格涂黑白两种颜色,保证每个格子上下左右的四个格子中最多只有一个格子与自己颜色相同,问有多少种涂法?结果$mod1000000007$ 思路:先只考虑一行有多少种涂法 $dp[i][0 ...
- Codeforces Round #594 (Div. 1) Ivan the Fool and the Probability Theory
题意:给你一个NxM的图,让你求有多少符合 “一个格子最多只有一个同颜色邻居”的图? 题解:首先我们可以分析一维,很容易就可以知道这是一个斐波那契计数 因为dp[1][m]可以是dp[1][m-1]添 ...
- Codeforces Round #594 (Div. 2) C. Ivan the Fool and the Probability Theory (思维,递推)
题意:给你一个\(n\)x\(m\)的矩阵,需要在这些矩阵中涂色,每个格子可以涂成黑色或者白色,一个格子四周最多只能有\(2\)个和它颜色相同的,问最多有多少种涂色方案. 题解:首先我们考虑一维的情况 ...
- C - Ivan the Fool and the Probability Theory---div2
题目连接:https://codeforces.com/contest/1248/problem/C 思路: 注意上下两排的关系,如果说上面那一排有两个方格连续,那么他相邻的两排必定和他相反,如果说当 ...
- 一起啃PRML - 1.2 Probability Theory 概率论
一起啃PRML - 1.2 Probability Theory @copyright 转载请注明出处 http://www.cnblogs.com/chxer/ A key concept in t ...
随机推荐
- 数据结构实验之排序一:一趟快排( SDUT 3398)
#include <stdio.h> #include <string.h> int a[110000]; void qusort(int l, int r, int a[]) ...
- Java 获取客户端真实IP地址
本文基于方法 HttpServletRequest.getHeader 和 HttpServletRequest.getRemoteAddr 介绍如何在服务器端获取客户端真实IP地址. 业务背景 服务 ...
- OpenFOAM清理计算结果(只保留原始的0,system,constant)
原视频下载地址:https://yunpan.cn/cMpyLZq8sWQgq(提取码:a08b)
- fluent-动网格-动态层
模型算例来源:http://blog.sina.com.cn/s/blog_599d8faa0100w4uj.html 原视频下载地址:http://yunpan.cn/cujM2FxLuGdLK ...
- java高级开发
(转载)博客原文链接:https://www.cnblogs.com/java1024/p/8594784.html 一.面试题基础总结 1. JVM结构原理.GC工作机制详解 答:具体参照:JVM结 ...
- 在Oracle Sql Developer中查看oracle版本
输入select * from v$version; 执行即可. --END-- 2019-11-29 12:34
- pip错误 ImportError: No module named 'pip_internal'
ubuntu16.04 - wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate sudo python get-pip.p ...
- Vue中的路由 以及默认路由跳转
https://router.vuejs.org/ vue路由配置: 1.安装 npm install vue-router --save / cnpm install vue-router --sa ...
- Dart抽象类和多态
/* Dart中抽象类: Dart抽象类主要用于定义标准,子类可以继承抽象类,也可以实现抽象类接口. 1.抽象类通过abstract 关键字来定义 2.Dart中的抽象方法不能用abstract声明, ...
- python的argparse模块parse_known_args()方法的使用
parse_known_args()方法的用处就是有些时候,你的选项配置可能不会在一个函数或包中调用完成 在很多使用,我们可能会需要根据一些输入的选项,比如在深度学习中,我们可能会根据传入的模型设置- ...