bzoj1088: [SCOI2005] Minesweeper Mine

Source: Internet
Author: User

Recursion. Given the number of mines in the second column, find out how many placement scenarios are in the first column. Enumerates the first recursion.

#include <cstdio> #include <cstring> #include <iostream> #include <algorithm>using namespace STD; #define REP (i,s,t) for (int i=s;i<=t;i++) #define CLR (x,c) memset (x,c,sizeof (x)) int read () {int X=0;char C=getchar (); while (!isdigit (c)) C=getchar () and while (IsDigit (c)) x=x*10+c-' 0 ', C=getchar (); return x;} const int NMAX=10005;CONST int Inf=0x7f7f7f7f;int a[nmax],ans[nmax],n;int main () {n=read (); Rep (I,1,n) a[i]=read (); int Res=0;if (A[2]<a[1]) {printf ("0\n"); return 0;} Rep (I,0,a[1]) {ans[1]=i;ans[2]=a[1]-i;rep (j,3,n+1) ans[j]=a[j-1]-ans[j-2]-ans[j-1];if (!ans[n+1]) res++;} printf ("%d\n", res); return 0;}

  

1088: [SCOI2005] Minesweeper mine time limit:10 Sec Memory limit:162 MB
submit:2943 solved:1741
[Submit] [Status] [Discuss] Description

I believe everyone has played the game of minesweeper. There are some thunder in a n*m matrix, you need to find out the ray based on some information. Halloween's here.
, "Yu" People in the country has a simple game of minesweeper, the rules of the game and the same as mine, if a lattice without thunder, then it inside the number
Represents the number of thunder inside the lattice with which it is 8 connected. Now the chessboard is nx2, and some of the squares in the first column are thunder, and the second column has no thunder, such as:
Since the first column of thunder may have multiple scenarios that meet the limits of the number of the second column, your task is to determine how many of the first quagliere are placed according to the information in the second column.
Scheme.

Input

The first behavior n, the second row has n number, in order the number of the second column in the lattice. (1<= N <= 10000)

Output

A number, that is, the number of thunder in the first column.

Sample Input2
1 1Sample Output2HINT Source [Submit] [Status] [Discuss]

bzoj1088: [SCOI2005] Minesweeper mine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.