BZOJ水一道~

枚举前两个位置是否放雷,模拟向下推。能够则ans++

#include "stdio.h"
#include "string.h" int a[10010],b[10010],n; int judge()
{
int i;
for (i=3;i<=n;i++)
{
b[i]=a[i-1]-b[i-1]-b[i-2];
if (b[i]<0) return 0;
if (b[i]>1) return 0;
}
if (b[n-1]+b[n]!=a[n]) return 0;
return 1;
}
int main()
{
int i,ans;
while (scanf("%d",&n)!=EOF)
{
for (i=1;i<=n;i++)
scanf("%d",&a[i]); if (a[1]>2) {printf("0\n");continue;}
ans=0; for (i=0;i<=a[1];i++)
{
b[1]=i; b[2]=a[1]-b[1]; if (b[2]<=1 && judge()==1)
ans++;
}
printf("%d\n",ans); }
return 0;
}

BZOJ 1088 水模拟的更多相关文章

  1. 【BZOJ 1088 扫雷Mine】模拟

    http://www.lydsy.com/JudgeOnline/problem.php?id=1088 2*N的扫雷棋盘,第二列的值a[i]记录第 i 个格子和它8连通的格子里面雷的数目. 第一列的 ...

  2. BZOJ 1088 扫雷Mine

    今天做了几道BZOJ的题,发现统观题目时还是很多很多都不会的,不过还是有几道时可以作的,以后要慢慢加强,争取多做题 BZOJ 1088 扫雷 其实本人平常不大玩扫雷的,就算玩也不是很好,不过看n*2的 ...

  3. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

  4. CodeForces.71A Way Too Long Words (水模拟)

    CodeForces71A. Way Too Long Words (水模拟) 题意分析 题怎么说你怎么做 没有坑点 代码总览 #include <iostream> #include & ...

  5. Bzoj 1088: [SCOI2005]扫雷Mine (DP)

    Bzoj 1088: [SCOI2005]扫雷Mine 怒写一发,算不上DP的游戏题 知道了前\(i-1\)项,第\(i\)项会被第二列的第\(i-1\)得知 设\(f[i]\)为第一列的第\(i\) ...

  6. BZOJ 1088: [SCOI2005]扫雷Mine【思维题,神奇的模拟+枚举】

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

  7. bzoj 刷水

    bzoj 3856: Monster 虽然是sb题,,但是要注意h可能<=a,,,开始忘记判了WA得很开心. #include <iostream> #include <cst ...

  8. bzoj刷水

    因为最近的生活太颓废总是不做题而被老师D了一番, 所以今天晚上到bzoj上去刷了几道水题.....   bzoj 4320: ShangHai2006 Homework 题目大意 维护一个支持两个操作 ...

  9. Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) A B C D 水 模拟 并查集 优先队列

    A. Broken Clock time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

随机推荐

  1. KMP算法题集

    模板 caioj 1177 KMP模板 #include<bits/stdc++.h> #define REP(i, a, b) for(register int i = (a); i & ...

  2. ASP.NET-model验证

    在ASP.NET的model中,可以定义下面的这种属性,来实现前台签证字符串 RegularExpression(@"(|.*(?=.{6,})(?=.*\d)(?=.*[a-zA-Z]). ...

  3. ASP.NET-后台cookie与前台JQUERY解析cookie

    在controller中给cookie赋值 HttpCookie cookie =newHttpCookie("pageInfo"); cookie["page_inde ...

  4. 【转载】How to Reset USB Device in Linux

    USB devices are anywhere nowadays, even many embedded devices replace the traditional serial devices ...

  5. hdu Swipe Bo(bfs+状态压缩)错了多次的题

    Swipe Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total S ...

  6. 关于Thread的那些事

    关于Thread的那些事 1 : 你能够调用线程的实例方法Join来等待一个线程的结束.比如: public static void MainThread() { Thread t = new Thr ...

  7. linux高级技巧:heartbeat+lvs(三)

    之前我们把LVS和heartbeat都单独进行了測试,是时候进行合并了 1.LVS+heartbeat:         首先显示我们的控制台:                        让这两个 ...

  8. 文本编辑工具 Vim

    Vim是Vi的升级版 vi和Vim的区别在于vi不会显示颜色,Vim会显示颜色 1.如果没有,可以安装 #yum install -y vim-enhanced

  9. [JZOJ 5875] [NOIP2018提高组模拟9.20] 听我说,海蜗牛 解题报告(BFS+二分)

    题目链接: http://172.16.0.132/senior/#main/show/5875 题目: 题解: 注意这题只能经过开放的港口 我们考虑用vector存下每个点不能到的点,并把并让vec ...

  10. 区间不相交&区间覆盖

    //code by virtualtan 2018 寒7 区间不相交 #include <cstdio> #include <algorithm> #define MAXN 1 ...