P2327-[SCOI2005]扫雷

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 typedef double db;
 5 #define INF 0x3f3f3f3f
 6 #define _for(i,a,b) for(int i = (a);i < b;i ++)
 7 #define _rep(i,a,b) for(int i = (a);i > b;i --)
 8 #define mod 20100403
 9 
10 inline ll read()
11 {
12     ll ans = 0;
13     char ch = getchar(), last = ' ';
14     while(!isdigit(ch)) last = ch, ch = getchar();
15     while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
16     if(last == '-') ans = -ans;
17     return ans;
18 }
19 inline void write(ll x)
20 {
21     if(x < 0) x = -x, putchar('-');
22     if(x >= 10) write(x / 10);
23     putchar(x % 10 + '0');
24 }
25 int n; 
26 int ans = 2;
27 int a[10003];
28 int b[10003];
29 void check()
30 {
31     _for(i,2,n+2)
32     {
33         b[i] = a[i-1]-b[i-1]-b[i-2];
34         if(b[i]!=1&&b[i])
35         {    ans --;break;}
36         if(i==n+1&&b[i])
37         {    ans --;break;}
38     }
39 }
40 int main()
41 {
42     n = read();
43     b[0] = 0;
44     _for(i,1,n+1)
45         a[i] = read();
46     
47     b[1] = 1;
48     check();
49     b[1] = 0;
50     check();
51     write(ans);
52     return 0;
53 }

 

转载于:https://www.cnblogs.com/Asurudo/p/11478189.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值