Lucky 7


Time Limit: 1 Second      Memory Limit: 65536 KB

BaoBao has just found a positive integer sequence  of length  from his left pocket and another positive integer  from his right pocket. As number 7 is BaoBao's favorite number, he considers a positive integer  lucky if  is divisible by 7. He now wants to select an integer  from the sequence such that  is lucky. Please tell him if it is possible.

Input

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

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

The second line contains  positive integers  (), indicating the sequence.

Output

For each test case output one line. If there exists an integer  such that  and  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".

原题地址:http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5762

题意:

给你一个n,和b,然后一个长度为n的数组A 问你是否有数组A的元素加上B能被7整除 如果可以输出Yes,不能输出No

代码:

#include<bits/stdc++.h>
using namespace std; int a[];
int main()
{
std::ios::sync_with_stdio(false);
int t;
while(cin>>t){
while(t--){
int n,num;
cin>>n>>num;
int flag=;
for(int i=;i<n;i++){
cin>>a[i];
}
for(int i=;i<n;i++){
if((a[i]+num)%==){
flag=;break;
}
}
if(flag)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
return ;
}

最新文章

  1. Linux内核分析:dup、dup2的实现
  2. 基于@AspectJ配置Spring AOP之一--转
  3. 关于AWR报告命中率指标的解释(转)
  4. MATLAB自定义配置
  5. mybatis 模糊查询 like
  6. 关于C语言读取多行数据的问题
  7. python之ftplib库
  8. Objective-C:三种文件导入的方式以及atomic和nonatomic的区别
  9. Maven配置文件说明
  10. 进程控制之更改用户ID和组ID
  11. 企业级搜索引擎Solr使用入门指南
  12. Linux下Tomcat安装、配置
  13. JavaScript键盘事件全面控制代码
  14. freemarker定义自己的标签错误(一)
  15. [cocos2d-x 3.0] 触摸显示器
  16. Smarty从配置文件读取的变量
  17. ubuntu16.04 禁用Guest用户
  18. matlab 向量法建数组(推荐)
  19. angular4.0单个标签不能同时使用ngFor和ngIf
  20. python - 代码缩进

热门文章

  1. P3509 [POI2010]ZAB-Frog
  2. P1419 寻找段落
  3. win10 update orchestratorservere禁用
  4. oracle设置自动清理归档日志脚本
  5. 2016广东工业大学校赛 E题 GDUT-oj1173
  6. SCOI2005 互不侵犯 [状压dp]
  7. Grep basic and practice
  8. ES6学习笔记(五)—— 编程风格
  9. bzoj1053 搜索
  10. 遍历文档内容,得到HTML层级结构