[线上网址](http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=378)

BaoBao has just found a positive integer sequence $a_1, a_2, \dots, a_n$ of length $n$ from his left pocket and another positive integer $b$ from his right pocket. As number 7 is BaoBao's favorite number, he considers a positive integer $x$ lucky if $x$ is divisible by 7. He now wants to select an integer $a_k$ from the sequence such that $(a_k+b)$ is lucky. Please tell him if it is possible.

Input

There are multiple test cases. The first line of the input is an integer \(T\) (about 100), indicating the number of test cases. For each test case:

The first line contains two integers \(n\) and \(b\) (\(1 \le n, b \le 100\)), indicating the length of the sequence and the positive integer in BaoBao's right pocket.

The second line contains \(n\) positive integers \(a_1, a_2, \dots, a_n\) (\(1 \le a_i \le 100\)), indicating the sequence.

Output

For each test case output one line. If there exists an integer \(a_k\) such that \(a_k \in \{a_1, a_2, \dots, a_n\}\) and \((a_k + b)\) is lucky, output "Yes" (without quotes), otherwise output "No" (without quotes).

Sample Input

4

3 7

4 5 6

3 7

4 7 6

5 2

2 5 2 5 2

4 26

100 1 2 4

Sample Output

No

Yes

Yes

Yes

Hint

For the first sample test case, as 4 + 7 = 11, 5 + 7 = 12 and 6 + 7 = 13 are all not divisible by 7, the answer is "No".

For the second sample test case, BaoBao can select a 7 from the sequence to get 7 + 7 = 14. As 14 is divisible by 7, the answer is "Yes".

For the third sample test case, BaoBao can select a 5 from the sequence to get 5 + 2 = 7. As 7 is divisible by 7, the answer is "Yes".

For the fourth sample test case, BaoBao can select a 100 from the sequence to get 100 + 26 = 126. As 126 is divisible by 7, the answer is "Yes".

#include<bits/stdc++.h>

using namespace std;
int a[1005];
int main()
{
int t;;
cin>>t;
while(t--){
int f=0;
int n,k;
cin>>n>>k;
for(int i=0;i<n;i++){
cin>>a[i];
if((a[i]+k)%7==0) f=1;
}
f?puts("Yes"):puts("No");
}
}

ZOJ18th省赛 Lucky 7的更多相关文章

  1. 2016第十三届浙江省赛 D - The Lucky Week

    D - The Lucky Week Edward, the headmaster of the Marjar University, is very busy every day and alway ...

  2. 『NYIST』第九届河南省ACM竞赛队伍选拔赛[正式赛二]- Nearly Lucky Number(Codeforces Beta Round #84 (Div. 2 Only)A. Nearly)

    A. Nearly Lucky Number time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  3. ACM选修HUST1058(市赛题) Lucky Sequence 同余定理

    Description Edward  得到了一个长度为  N  的整数序列,他想找出这里面有多少个“幸运的”连续子序列.一个连续子序列被称为“幸运的”,当且仅当该子序列内的整数之和恰好是  K  的 ...

  4. HDU6235-Permutation-水题-2017中国大学生程序设计竞赛-哈尔滨站-重现赛

    Permutation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Tot ...

  5. 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)

    摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...

  6. HDU 4768 Flyer (2013长春网络赛1010题,二分)

    Flyer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  7. HDU 6235.Permutation (2017中国大学生程序设计竞赛-哈尔滨站-重现赛)

    Permutation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Tot ...

  8. 11/1 NOIP 模拟赛

    11.1 NOIP 模拟赛 期望得分:50:实际得分:50: 思路:暴力枚举 + 快速幂 #include <algorithm> #include <cstring> #in ...

  9. 模拟赛小结:2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest

    2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest 2019年10月11日 15:35-20:35(Solved 8,Penalty 675 ...

随机推荐

  1. 写一个quick sort

    #include <stdio.h> #include <stdlib.h> //int a[]={1000,10000,9,10,30,20,50,23,90,100,10} ...

  2. 设计模式之第22章-组合模式(Java实现)

    设计模式之第22章-组合模式(Java实现) “鱼哥,有没有什么模式是用来处理树形的“部分与整体”的层次结构的啊.”“当然”“没有?”“有啊.别急,一会人就到了.” 组合模式之自我介绍 “请问你是?怎 ...

  3. U盘的容量变小了怎么办?

    之前买了个U盘,后来给朋友装系统弄成U盘启动盘了,就发现U盘容量变少了几百兆,原来是因为做U盘启动盘的时候,U盘启动盘制作软件都是把写入U盘的PE文件隐藏了,防止用户不小心删除文件. 所以说这些空间应 ...

  4. 牛客网暑期ACM多校训练营(第一场):D-Two Graphs

    链接:D-Two Graphs 题意:给出图G1和G2,求G2的子图中和G1同构的个数. 题解:只有8个点,暴力枚举G2的点每个排列,让G1映射到G2中,求出同构个数a.同构的G2就是在G1有边的对应 ...

  5. 软件工程概论课堂测试一————添加新课程(web)

    设计思想 三个文件Class_add.java  add.jsp  addInput.jsp Class_add.java : 内封装方法:连接数据库.向数据库添加课程信息.判断非合理的输入情况.判断 ...

  6. BETA0

    目录 过去存在的问题 任务分工 规范 后端总结 卉卉 家灿 前端总结 绪佩 青元 恺琳 宇恒 丹丹 算法&API接口 家伟 鸿杰 一好 文档&博客撰写 政演 产品功能 我们已经坐了哪些 ...

  7. Eclipse中安装svn的插件安装和使用

    先关闭Eclipse 步骤一:下载site-1.10.11.zip  将其解压 解压后目录 步骤二:创建一个文件夹svn,将解压后的文件copy到svn路径下 步骤三:打开Eclipse安装路径: e ...

  8. 用Margin还是用Padding?

    用margin还是用padding这个问题是每个学习CSS进阶时的必经之路. CSS边距属性定义元素周围的空间.通过使用单独的属性,可以对上.右.下.左的外边距进行设置.也可以使用简写的外边距属性同时 ...

  9. Crash的游戏 [组合+递推]

    题面 思路 问题转化 这个问题的核心在于,我们需要把"加入一个球.拿出一个球"这两个操作转化一下 因为显然两个操作同时进行的话,我们没有办法从单纯的组合意义去分析 我们首先把$m$ ...

  10. BZOJ2743 [HEOI2012]采花 【离线 + 树状数组】

    题目 萧芸斓是Z国的公主,平时的一大爱好是采花. 今天天气晴朗,阳光明媚,公主清晨便去了皇宫中新建的花园采花.花园足够大,容纳了n朵花,花有c种颜色(用整数1-c表示),且花是排成一排的,以便于公主采 ...