HRBUST 1005 Counting Subsequences

题目:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1005

代码:

#include<stdio.h>
#include<map>
using namespace std;
int main()
{
    int n,a;
    while (~scanf("%d",&n))
        while(n--)
        {
            map<int,int>p;
            int k=0,u=0;
            scanf("%d",&a);
            p[0]=1;
            while(a--)
            {
                int b;
                scanf("%d",&b);
                k=k+b;
                p[k]++;
                u=u+p[k-47];
            }
            printf("%d\n",u);
        }
    return 0;
}

分析:

不知道这种方法是否可以代替动态规划



                                                                                 11274

                                                              11237   

                                               11190

                           10143

             10096

     49

2  

7
2 47 10047 47    1047    47    47


too difficult

你可能感兴趣的:(HRBUST 1005 Counting Subsequences)