hdu-5776 sum(同余)
题目链接:
sum
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 131072/131072 K (Java/Others)
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.
/************************************************
┆ ┏┓ ┏┓ ┆
┆┏┛┻━━━┛┻┓ ┆
┆┃ ┃ ┆
┆┃ ━ ┃ ┆
┆┃ ┳┛ ┗┳ ┃ ┆
┆┃ ┃ ┆
┆┃ ┻ ┃ ┆
┆┗━┓ ┏━┛ ┆
┆ ┃ ┃ ┆
┆ ┃ ┗━━━┓ ┆
┆ ┃ AC代马 ┣┓┆
┆ ┃ ┏┛┆
┆ ┗┓┓┏━┳┓┏┛ ┆
┆ ┃┫┫ ┃┫┫ ┆
┆ ┗┻┛ ┗┻┛ ┆
************************************************ */ #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <stack> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
if(!p) { puts("0"); return; }
while(p) stk[++ tp] = p%10, p/=10;
while(tp) putchar(stk[tp--] + '0');
putchar('\n');
} const LL mod=1e9+7;
const double PI=acos(-1.0);
const int inf=1e9;
const int N=1e5+10;
const int maxn=(1<<8);
const double eps=1e-8; int vis[5600]; int main()
{ int t;
read(t);
while(t--)
{
mst(vis,0);
int n,m,sum=0,flag=0,x;
read(n);read(m);
vis[0]=1;
For(i,1,n)
{
read(x);
sum+=x;
int temp=sum%m;
if(vis[temp])flag=1;
vis[temp]=1;
}
if(flag)cout<<"YES\n";
else cout<<"NO\n";
} return 0;
}
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 前缀和
sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submi ...
- 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
猜了一下,发现对了.n>m是一定有解的.所以最多m*m暴力,一定能找到.而T较小,所以能过. #pragma comment(linker, "/STACK:1024000000,10 ...
- 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 - 4704 sum 大数取余+欧拉降幂
Sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submi ...
随机推荐
- 邁向IT專家成功之路的三十則鐵律 鐵律二十六:IT人閱讀之道-慎選
IT人經常一整天工作回來早已用腦過度,此時收看什麼樣的電視節目,以及閱讀甚麼樣的書籍.聽什麼樣的音樂與有聲書最適合我們,讓我們可以在放鬆之餘,還能夠讓自己內在的心靈與外在的能力繼續成長呢? 身為IT工 ...
- minimum-moves-to-equal-array-elements-ii(好)
https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/ package com.company; import ...
- BumpMapping [转]
http://fabiensanglard.net/bumpMapping/index.php Fabien Sanglard's Website Home About FAQ Email Rss T ...
- intent 支持的action 动作
String ACTION_AIRPLANE_MODE_CHANGED Broadcast Action: The user has switched the phone into or out of ...
- Opencv 图片边缘检测和最小外接矩形
#include "core/core.hpp" #include "highgui/highgui.hpp" #include "imgproc/i ...
- OpenGL之路(七)为立方体加入丰富色彩
在立方体的六个面贴上不同的颜色,假设想达到混合颜色的效果,能够參照立方体的前面代码在每一行前都加上颜色 代码例如以下 #include <gl/glut.h> #pragma commen ...
- vue2.0 + vux (三)MySettings 页
1.MySettings.vue <!-- 我的设置 --> <template> <div> <img class="img_1" sr ...
- cvpr2017-code-etc
cvpr2017: code: http://staffhome.ecm.uwa.edu.au/~00053650/code.html
- 成长为 iOS 大 V 的秘密
成长为 iOS 大 V 的秘密 前言 毫不谦虚地说,我是国内 iOS 开发的大 V.我从 2011 年底开始自学 iOS 开发,经过 3 年时间,到 2014 年底,我不但写作了上百篇 iOS 相 ...
- IP分配及网段划分
1.IP我们先来了解一下3类常用的IP A类IP段 0.0.0.0 到127.255.255.255 B类IP段 128.0.0.0 到191.255.255.255 C类IP段 192.0.0. ...