# BestCoder Round #85 sum

Given a sequence, you‘re asked whether there exists a consecutive subsequence whose sum is divisible by m. output YES, otherwise output NO.

The first line of the input has an integer T (1≤T≤10), which represents the number of test cases. For each test case, there are two lines: 1.The first line contains two positive integers n, m (1≤n≤100000, 1≤m≤5000). 2.The second line contains n positive integers x (1≤x≤100) according to the sequence.

Output T lines, each line print a YES or NO.

```2
3 3
1 2 3
5 7
6 6 6 6 6
```

```YES
NO```

``` 1 #include <cstdio>
2 #define N 100100
3
4 int main()
5 {
6     int t,n,m,a[N];
7     int flag=0;
8     scanf("%d",&t);
9     while(t--){
10         scanf("%d %d",&n,&m);
11         int sum=0;
12         int k=1;
13         for(int j=1;j<=n;j++){
14            scanf("%d",&a[j]);
15         }
16         for(int i=1;i<=n;i++){
17                while(k<=n&&sum<m){
18                   sum+=a[k++];
19                }
20                if(sum==m){
21                      flag=1;
22                      break;
23                }
24                sum-=a[i];
25
26         }
27         if(flag==1){
28             printf("YES\n");
29         }else
30             printf("NO\n");
31         flag=0;
32     }
33     return 0;
34 } ```

## hdu 5163 Taking Bus (BestCoder Round #27)

Taking Bus                                                               Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 501    Accepted Submission(s): 203 Problem Description Bestland has a v

## BestCoder Round #9

BestCoder Round #9 题目链接 A:暴力枚举一个数字,就能求出另一个数字,for一遍即可 B:博弈,判断前n - 1个开头连续1的奇偶性即可 C:先预处理出每个点对应哪几个点,每次查询计算一次即可 代码: A: #include <cstdio> #include <cstring> #include <vector> #include <set> #include <algorithm> #include <cmath&g

## BestCoder Round #29——A--GTY&#39;s math problem（快速幂（对数法））、B--GTY&#39;s birthday gift（矩阵快速幂）

GTY's math problem Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0 Problem Description GTY is a GodBull who will get an Au in NOI . To have more time to learn alg