题目描述

输入输出格式

输入格式:

第一行为N,第二行有N个数,依次为第二列的格子中的数。(1<= N <= 10000)

输出格式:

一个数,即第一列中雷的摆放方案数。

输入输出样例

输入样例#1: 复制

2
1 1
输出样例#1: 复制

2

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 2147483647
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define ri register int
template <class T> inline T min(T a, T b, T c)
{
return min(min(a, b), c);
}
template <class T> inline T max(T a, T b, T c)
{
return max(max(a, b), c);
}
template <class T> inline T min(T a, T b, T c, T d)
{
return min(min(a, b), min(c, d));
}
template <class T> inline T max(T a, T b, T c, T d)
{
return max(max(a, b), max(c, d));
}
#define pi acos(-1)
#define me(x, y) memset(x, y, sizeof(x));
#define For(i, a, b) for (int i = a; i <= b; i++)
#define FFor(i, a, b) for (int i = a; i >= b; i--)
#define mp make_pair
#define pb push_back
const int maxn = ;
#define mod 100003
const int N=; // name*******************************
int f[N][];
int n;
int num[];
int ans=;
// function******************************
int counter(int x)
{
int res=;
while(x)
{
x&=(x-);
res++;
}
return res;
} //***************************************
int main()
{
//freopen("test.txt", "r", stdin);
cin>>n;
For(i,,n)
cin>>num[i];
f[][]=;
f[][]=;
For(i,,n)
{
For(j,,)
{
if(counter(j)!=num[i-]||counter(j>>)>num[i])continue;
f[i][j]+=f[i-][(j<<)%]+f[i-][((j<<)%)|];
}
} For(i,,)
{
if(counter(i)==num[n-]&&counter(i>>)==num[n])
ans+=f[n][i];
}
cout<<ans; return ;
}

P2327 [SCOI2005]扫雷的更多相关文章

  1. bzoj1088 P2327 [SCOI2005]扫雷

    P2327 [SCOI2005]扫雷 emmmmm.....这题真可以用状压写 因为每个数字只对3个格子有影响,相当于只有2^3=8种状态,所以可以用状压瞎搞 我们用8个数字代表二进制下的8种状态 0 ...

  2. 洛谷 P2327 [SCOI2005]扫雷

    P2327 [SCOI2005]扫雷 https://www.luogu.org/problem/show?pid=2327 题目描述 输入输出格式 输入格式: 第一行为N,第二行有N个数,依次为第二 ...

  3. 洛谷P2327 [SCOI2005]扫雷 [2017年5月计划 清北学堂51精英班Day1]

    P2327 [SCOI2005]扫雷 题目描述 输入输出格式 输入格式: 第一行为N,第二行有N个数,依次为第二列的格子中的数.(1<= N <= 10000) 输出格式: 一个数,即第一 ...

  4. 【题解】Luogu P2327 [SCOI2005]扫雷

    Luogu P2327 [SCOI2005]扫雷 Description 相信大家都玩过扫雷的游戏.那是在一个n*m的矩阵里面有一些雷,要你根据一些信息找出雷来.万圣节到了,"余" ...

  5. P2327 [SCOI2005]扫雷(递推)

    题目链接: https://www.luogu.org/problemnew/show/P2327 题目描述 相信大家都玩过扫雷的游戏.那是在一个$n*m$的矩阵里面有一些雷,要你根据一些信息找出雷来 ...

  6. Luogu P2327 [SCOI2005]扫雷【递推/数学】By cellur925

    题目传送门 推了好久啊.看来以后要多玩扫雷了qwq. 其实本题只有三种答案:0.1.2. 对于所有第一列,只要第一个数和第二个数确定后,其实整个数列就确定了,我们可以通过这个递推式得出 sec[i-] ...

  7. 洛谷P2327 [SCOI2005] 扫雷

    题目描述 输入输出格式 输入格式: 第一行为N,第二行有N个数,依次为第二列的格子中的数.(1<= N <= 10000) 输出格式: 一个数,即第一列中雷的摆放方案数. 输入输出样例 输 ...

  8. luogu P2327 [SCOI2005]扫雷

    很好的一道题,仔细思索(在y^3 dalao的帮助下)可以发现答案只有0 1 2三种情况 直接枚举第一位有没有雷,就可以递推了qwq 附上y^3大佬的blogs https://blog.csdn.n ...

  9. 【递推】BZOJ 1088: [SCOI2005]扫雷Mine

    1088: [SCOI2005]扫雷Mine Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 2275  Solved: 1328[Submit][St ...

随机推荐

  1. Batch Norm、Layer Norm、Weight Norm与SELU

    加速网络收敛——BN.LN.WN与selu 自Batch Norm出现之后,Layer Norm和Weight Norm作为Batch Norm的变体相继出现.最近又出来一个很”简单”的激活函数Sel ...

  2. Java线程池相关类-Executor框架

    1.Executor 接口源码: public interface Executor { /** * Executes the given command at some time in the fu ...

  3. Android手势密码实现

    图 二.实现思路: 1. 正上方的提示区域,用一个类(LockIndicator.java)来实现,自定义view来绘制9个提示图标: 2. 手势密码绘制区域,用一个类(GestureContentV ...

  4. Mouse For Winpad

    Mouse For Winpad 用WIN10的平板模式玩游戏总会到一些兼容性问题,之前在推Re:LieF的时候就遇到了触屏不能像鼠标指针一样进行游戏,于是猜想一定是程序没进行标准化MFC的编程.于是 ...

  5. python学习手册中的一些易忘的点(前三部分)

    1.ubuntu下让python脚本可直接运行: test.py文件(后缀可省)#!/usr/bin/pythonprint('wwwww') sudo chmod +x ./test.py (sud ...

  6. 离线安装SharePoint2016

    离线安装SharePoint2016的过程中,遇到了不少问题,该文章将安装过程尽量详细描述,供自己后续参考,请不要嫌文章啰嗦哈. 本人使用的是Windows Server 2012 R2 Standa ...

  7. Linux服务器安装redis数据库教程

    前面小Alan给大家说了jdk的安装,这篇跟大家聊聊redis非关系型数据库在Linux服务器的安装. redis简单介绍 REmote DIctionary Server(Redis) 是一个由Sa ...

  8. 【Java】生成UUID

    import java.util.UUID; public class MainProcess { public static void main(String[] args) { UUID uuid ...

  9. Linux ulimit命令详解

    ulimit 是一个计算机命令,用于shell启动进程所占用的资源,可用于修改系统资源限制 命令常用参数 -H 设置硬资源限制. -S 设置软资源限制. -a 显示当前所有的资源限制. -c size ...

  10. 铁乐学python_shelve模块详解

    python序列化模块-shelve模块详解 shelve:vt. 将(书等)放置在架子上:搁置,将某事放到一旁不予考虑:将-搁在一边:装搁架于: 个人感觉有点像字典缓存?暂时搁置到一旁的意思? 研究 ...