zoukankan      html  css  js  c++  java
  • HDU 5776 sum

    猜了一下,发现对了。n>m是一定有解的。所以最多m*m暴力,一定能找到。而T较小,所以能过。

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    #include<vector>
    #include<map>
    #include<set>
    #include<queue>
    #include<stack>
    #include<iostream>
    using namespace std;
    typedef long long LL;
    const double pi=acos(-1.0),eps=1e-8;
    void File()
    {
        freopen("D:\in.txt","r",stdin);
        freopen("D:\out.txt","w",stdout);
    }
    inline int read()
    {
        char c = getchar();  while(!isdigit(c)) c = getchar();
        int x = 0;
        while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); }
        return x;
    }
    
    int a[100000+10],sum[100000+10];
    int n,m;
    
    int main()
    {
        int T; scanf("%d",&T);
        while(T--)
        {
            scanf("%d%d",&n,&m);
            for(int i=1;i<=n;i++) scanf("%d",&a[i]);
            if(n>m) { printf("YES
    "); continue; }
            sum[0]=0; for(int i=1;i<=n;i++) sum[i]=a[i]+sum[i-1];
            int ans=0;
            for(int i=1;i<=n;i++) for(int j=i;j<=n;j++)
                if((sum[j]-sum[i-1])%m==0) ans=1;
            if(ans==1) printf("YES
    "); else printf("NO
    ");
        }
        return 0;
    }
  • 相关阅读:
    解决粘包问题
    粘包问题
    模拟ssh功能
    套接字接上链接循环
    套接字加入通讯循环
    简单通信
    网络编程
    单例模式
    记录一下:chrome上,把网页保存为文件的插件
    centos6.5 64bit 实现root开机自动登录X桌面
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5724865.html
Copyright © 2011-2022 走看看