Codeforces 1178C. Tiles
考虑一块块填,首先 $(1,1)$ 有 $4$ 种方案
然后根据 $(1,1)$ 的右边颜色,$(1,2)$ 有两种方案,$(1,3)$ 根据 $(1,2)$ 也有两种方案...
考虑 $(2,1)$ 根据 $(1,1)$ 有两种方案,$(3,1)$ 也有两种....
然后发现,如果我们确定了 $(1,1)$ 到 $(1,m)$ ,确定了 $(1,1)$ 到 $(n,1)$ ,那么之后所有位置都可以根据它们的左边颜色和上面颜色确定
那么方案数即为填左边一列和上边一行的方案数
那么答案整理一下就是 $2^{n+m}$
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int read()
{
int x=,f=; char ch=getchar();
while(ch<''||ch>'') { if(ch=='-') f=-; ch=getchar(); }
while(ch>=''&&ch<='') { x=(x<<)+(x<<)+(ch^); ch=getchar(); }
return x*f;
}
const int mo=;
int n,m;
inline int ksm(int x,int y)
{
int res=;
while(y) { if(y&) res=1ll*res*x%mo; x=1ll*x*x%mo; y>>=; }
return res;
}
int main()
{
n=read(),m=read();
printf("%d\n",ksm(,n+m));
return ;
}
Codeforces 1178C. Tiles的更多相关文章
- Codeforces 1500D - Tiles for Bathroom(贪心+队列)
Codeforces 题面传送门 & 洛谷题面传送门 首先先讲一发我的 \(n^2q\log n\) 的做法,虽然没有付诸实现并且我也深知它常数巨大过不去,但是我还是决定讲一讲(大雾 考虑设 ...
- @codeforces - 1214H@ Tiles Placement
目录 @description@ @solution@ @part - 1@ @part - 2@ @accepted code@ @details@ @description@ 给定一个 n 点的树 ...
- Codeforces Round #292 (Div. 1) B. Drazil and Tiles 拓扑排序
B. Drazil and Tiles 题目连接: http://codeforces.com/contest/516/problem/B Description Drazil created a f ...
- CodeForces - 516B Drazil and Tiles(bfs)
https://vjudge.net/problem/CodeForces-516B 题意 在一个n*m图中放1*2或者2*1的长方形,问是否存在唯一的方法填满图中的‘.’ 分析 如果要有唯一的方案, ...
- Codeforces Round #292 (Div. 1) B. Drazil and Tiles (类似拓扑)
题目链接:http://codeforces.com/problemset/problem/516/B 一个n*m的方格,'*'不能填.给你很多个1*2的尖括号,问你是否能用唯一填法填满方格. 类似t ...
- Codeforces Round #292 (Div. 1) - B. Drazil and Tiles
B. Drazil and Tiles Drazil created a following problem about putting 1 × 2 tiles into an n × m gri ...
- 【codeforces 516B】Drazil and Tiles
题目链接: http://codeforces.com/problemset/problem/516/B 题解: 首先可以得到一个以‘.’为点的无向图,当存在一个点没有边时,无解.然后如果这个图边双联 ...
- CodeForces 516B Drazil and Tiles 其他
原文链接http://www.cnblogs.com/zhouzhendong/p/8990658.html 题目传送门 - CodeForces 516B 题意 给出一个$n\times m$的矩形 ...
- Drazil and Tiles CodeForces - 516B (类拓扑)
Drazil created a following problem about putting 1 × 2 tiles into an n × m grid: "There is a gr ...
随机推荐
- Jmeter -- 脚本录制
步骤如下: 1. 添加http代理服务器(Add -> Non-TestElement -> HTTP(S)Test Script Recorder) 2. 对http代理进行配置,如下图 ...
- python-numpy-1
mean() mean() 函数定义: numpy.``mean(a, axis=None, dtype=None, out=None, keepdims=<class numpy._globa ...
- Python 中的 getopt 模块
sys 模块:可以得到用户在命令行输入的参数 getopt模块:专门用来处理输入的命令行参数 用户在命令行中输入参数,sys模块得到该参数,getopt模块处理该参数 sys模块: import sy ...
- Lasso回归总结
Ridge回归 由于直接套用线性回归可能产生过拟合,我们需要加入正则化项,如果加入的是L2正则化项,就是Ridge回归,有时也翻译为岭回归.它和一般线性回归的区别是在损失函数上增加了一个L2正则化的项 ...
- HearthBuddy Plugin编写遇到的问题
错误1 赋值问题 貌似编译器版本有点低,无法识别C#的高级语法糖 属性的初始值,必须是public bool IsEnabled { get{return true;} } 不能写成public bo ...
- PHP中获取数组中单列的值
PHP中获取数组中单列的值如下: 利用PHP中的数组函数 array_column():返回数组中某个单列的值.(PHP 5.5+适用) 语法: array_column(array,column_k ...
- glance-----常用命令
#查看镜像 openstack image list glance image-list #镜像导出 openstack image save <image_id> --file < ...
- kettle的数据库配置的表分析
以下场景,用mysql来举例说明.本文是在初步了解了kettle的数据库配置之后,做的总结和分析.将kettle中的配置用数据库管理的时候,在创建了一个新的数据库,还没有做任何kettle中的job和 ...
- Linux命令之文件和目录操作命令(一)—— ls
本文介绍了ls命令的最常用法. 1.用法: ls [选项][目录名或文件名] 2.选项: -l 使用长格式显示目录或文件的详细信息 -a 显示隐藏文件 -h 人性化显示文件或目录的大小 -d 显示目录 ...
- 如何解决使用 JMeter 时遇到的问题
这是对 JMeter 官方网站上一篇文章的翻译.点击这里可以访问原文JMeterTroubleShooting. • check the log file. This is normally in t ...