Android Build KeyStore file

Source: Internet
Author: User

Title Link: http://acm.fzu.edu.cn/problem.php?pid=2170

Stick a Baka the code souvenir.

There is a problem with the data, the input string length does not exceed 1000

#include <iostream> #include <cstdio> #include <cstring> #include <string> #include < algorithm> #include <map> #include <queue> #include <stack> #include <cmath> #include < Vector> #define INF 0x3f3f3f3f#define inf 0x3fffffffffffffffll#define eps 1e-9#define pi acos ( -1.0) using namespace std ; typedef long long ll;const int maxn=1000+2;const int mod=1000000007;int Dp[maxn][maxn];char str[maxn<<1];int Main    () {//freopen ("In.txt", "R", stdin);    Freopen ("OUT.txt", "w", stdout);    int t,n;    scanf ("%d", &t);        while (t--) {scanf ("%d", &n);        Memset (Dp,0,sizeof (DP));        scanf ("%s", str+1);        Dp[0][0]=1;        int k;                for (int i=0;i<=n;++i) for (int j=0;j<=n;++j) {if (!dp[i][j]) continue;                k=i+j+1;                        if ((i&1) && (j&1)) {if (str[k]== ' B ') { Dp[i][j+1]+=dp[i][J];                        DP[I+1][J]+=DP[I][J];                        if (dp[i][j+1]>=mod) Dp[i][j+1]-=mod;                    if (dp[i+1][j]>=mod) Dp[i+1][j]-=mod;                    }} else if (i&1) {if (str[k]== ' W ')                        {DP[I][J+1]+=DP[I][J];                    if (dp[i][j+1]>=mod) Dp[i][j+1]-=mod;                        } else {dp[i+1][j]+=dp[i][j];                    if (dp[i+1][j]>=mod) Dp[i+1][j]-=mod;                    }} else if (j&1) {if (str[k]== ' W ')                        {DP[I+1][J]+=DP[I][J];                    if (dp[i+1][j]>=mod) Dp[i+1][j]-=mod;                        } else {dp[i][j+1]+=dp[i][j]; if (dp[i][j+1]>=mod) Dp[i][j+1]-=mod;                        }} else {if (str[k]== ' W ') {                        DP[I][J+1]+=DP[I][J];                        DP[I+1][J]+=DP[I][J];                        if (dp[i][j+1]>=mod) Dp[i][j+1]-=mod;                    if (dp[i+1][j]>=mod) Dp[i+1][j]-=mod;        }}} int ans=dp[n][n];    printf ("%d\n", ans); } return 0;}


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.