hdu_5965_ Minesweeper (Recursive)

Source: Internet
Author: User

Topic Link: hdu_5965_ minesweeper

Test instructions

Chinese, or see for yourself.

Exercises

Live game This problem with the pressure DP, but now think about it still really want to complicate, calm down carefully think about, in fact, the first i-1 to determine, then the first I is also OK, can be handed out.

Set Dp[i] to show the number of mines in column I, and then enumerate the number of mines in the first column, you can roll out all the thunder, and then count the contributions.

1#include <bits/stdc++.h>2 #defineF (I,A,B) for (int i=a;i<=b;i++)3 using namespacestd;4 5 Const intn=1e4+7, p=1e8+7;6 7 CharS[n];8 intNum[n],dp[n],t,ans,n;9 Ten intMain () One { Ascanf"%d",&t); -      while(t--) -     { thescanf"%s", s+1), ans=0; -N=strlen (s+1); -          for(intI=1; i<=n;i++) num[i]=s[i]-'0'; -F (I,0, num[1]) +         { -dp[1]=i; +             if(i>2) Break; A             intJ; at              for(j=2; j<=n;j++) -             { -                 intnow=num[j-1]-dp[j-1]-dp[j-2]; -                 if(now>2|| now<0) Break; -dp[j]=Now ; -             } in             if(j<=n| | dp[n-1]+dp[n]!=num[n])Continue; -             intan=1; toF (J,1, N)if(dp[j]==1) an*=2, an%=P; +ans+=an,ans%=P; -         } theprintf"%d\n", ans); *     } $     return 0;Panax Notoginseng}
View Code

hdu_5965_ Minesweeper (Recursive)

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.