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-;
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 = ;
while(isdigit(c)) { x = x * + c - ''; c = getchar(); }
return x;
} int a[+],sum[+];
int n,m; int main()
{
int T; scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++) scanf("%d",&a[i]);
if(n>m) { printf("YES\n"); continue; }
sum[]=; for(int i=;i<=n;i++) sum[i]=a[i]+sum[i-];
int ans=;
for(int i=;i<=n;i++) for(int j=i;j<=n;j++)
if((sum[j]-sum[i-])%m==) ans=;
if(ans==) printf("YES\n"); else printf("NO\n");
}
return ;
}
HDU 5776 sum的更多相关文章
- HDU 5776 sum (模拟)
sum 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5776 Description Given a sequence, you're asked ...
- HDU 5776 sum(抽屉原理)
题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=5776 Problem Description Given a sequence, you're ask ...
- HDU 5776 sum (思维题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5776 题目让你求是否有区间的和是m的倍数. 预处理前缀和,一旦有两个数模m的值相同,说明中间一部分连续 ...
- HDU 5776 sum (前缀和)
题意:给定 n 个数,和 m,问你是不是存在连续的数和是m的倍数. 析:考虑前缀和,如果有两个前缀和取模m相等,那么就是相等的,一定要注意,如果取模为0,就是真的,不要忘记了,我当时就没记得.... ...
- HDU 5776 sum (BestCoder Round #85 A) 简单前缀判断+水题
分析:就是判断简单的前缀有没有相同,注意下自身是m的倍数,以及vis[0]=true; #include <cstdio> #include <cstdlib> #includ ...
- hdu 5776 sum 前缀和
sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submi ...
- HDU 5776 sum( 鸽巢定理简单题 )
链接:传送门 题意:给一个长为 n 的串,问是否有子串的和是 m 的倍数. 思路:典型鸽巢定理的应用,但是这里 n,m 的大小关系是不确定的,如果 n >= m 根据定理可以很简单的判定是一定有 ...
- HDOJ(HDU).1258 Sum It Up (DFS)
HDOJ(HDU).1258 Sum It Up (DFS) [从零开始DFS(6)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双 ...
- HDU 5776
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5776 求是否有区间的和是m的倍数 预处理前缀和,一旦有两个数模m的值相同,说明中间一部分连续子列可以组 ...
随机推荐
- Hibernate 注解说明
转:http://blog.csdn.net/u012312373/article/details/46566081 1.类级别注解 @Entity 映射实体类 @Table 映 ...
- many bugs report when test bcm bt/wifi chip
after change aerial , many bugs diappear .
- incomplete type is not allowed
keil环境下,报错#70: incomplete type is not allowed,解决 mqtt_conf.h 定义了一个结构体 mqtt_buffer.h #include <std ...
- linux重要目录说明
1 home :root用户的home 目录是root,普通用户的home 目录是/home,users/(不要随便使用root权限,小白容易改错东西哒) 2 bin:常用可执行文件:/bin./us ...
- Linux文件挂载命令mount
在linux系统中硬盘.u盘.光驱等其他设备都需要挂载后才能正常使用.下面是对挂载命令mount使用方法的一些总结. 文件挂载命令mountmount [-t 文件系统类型][-L卷标名][-o特殊选 ...
- 将可执行exe文件注册成windows服务
要把应用程序添加为服务,你需要两个小软件:Instsrv.exe和Srvany.exe.Instsrv.exe可以给系统安装和删除服务,Srvany.exe可以让程序以服务的方式运行.这两个软件都包含 ...
- wakeup_train运行遇到的问题记录
运行前需要更改的地方: 1.matlab安装的路径以及matlab的license文件 2.噪声的路径;background.scp,以及噪声文件 3.run.sh文件中一处f ...
- 关于并行计算的Scan操作
simple and common parallel algorithm building block is the all-prefix-sums operation. In this chapte ...
- Linux下安装awstats日志统计分析
1. 下载安装 cd /data/software wget http://prdownloads.sourceforge.net/awstats/awstats-7.0-1.noarch.rpm 2 ...
- CentOS启动不显示图形界面直接进入命令行模式
我现在用的是 CentOS 6.3 开机后进入图形化界面还是进入命令行取决于inittab文件中的配置.该文件位于etc目录下. # vi /etc/inittab 找到下面的语句: # Defaul ...