ZOJ18th省赛 Lucky 7
[线上网址](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的更多相关文章
- 2016第十三届浙江省赛 D - The Lucky Week
D - The Lucky Week Edward, the headmaster of the Marjar University, is very busy every day and alway ...
- 『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 ...
- ACM选修HUST1058(市赛题) Lucky Sequence 同余定理
Description Edward 得到了一个长度为 N 的整数序列,他想找出这里面有多少个“幸运的”连续子序列.一个连续子序列被称为“幸运的”,当且仅当该子序列内的整数之和恰好是 K 的 ...
- HDU6235-Permutation-水题-2017中国大学生程序设计竞赛-哈尔滨站-重现赛
Permutation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Tot ...
- 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)
摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...
- HDU 4768 Flyer (2013长春网络赛1010题,二分)
Flyer Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- HDU 6235.Permutation (2017中国大学生程序设计竞赛-哈尔滨站-重现赛)
Permutation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Tot ...
- 11/1 NOIP 模拟赛
11.1 NOIP 模拟赛 期望得分:50:实际得分:50: 思路:暴力枚举 + 快速幂 #include <algorithm> #include <cstring> #in ...
- 模拟赛小结: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 ...
随机推荐
- 什么是 IRC?
IRC是Internet Relay Chat 的英文缩写,中文一般称为互联网中继聊天.它是由芬兰人Jarkko Oikarinen于1988年首创的一种网络聊天协议.经过十年的发展,目前世界上有超过 ...
- Abstract Factory 抽象工厂(创建型模式)
1.常规的对象创建方法(以更换QQ空间主题为例) (这里的常规对象指的是由于业务需求,当前实例化的对象有可能被其他相似的对象(有着共同的特性)所取代,例如更换手机铃声:一首歌取代另一首歌(词,曲,和声 ...
- PAT——甲级1042:Shuffling Mashine
终于做到甲级了 就一个感觉....题目是真的看不懂,亏我还是四六级都过了的人....可是看完题愣是一点都不懂是什么意思. 1042 Shuffling Machine (20 point(s)) Sh ...
- SPOJ 364 Pocket Money 简单DP
跟矩阵链乘同类型的题…… 输出用%llu不是%I64u…… 几组数据: 141+2*4+3*4+5*00*5*6+7*3+23+0+6+7+0+44*5+7*1*1+12*0+3*4*0+5*6+7+ ...
- stuff使用感悟
select ),t2.CityId) from t t2 where not exists( from Web_UserCity uc where UserName='user001' and uc ...
- 文件i/o函数 open/close
一:open open函数可以打开或创建一个文件. #include <sys/types.h> #include <sys/stat.h> #include <fcnt ...
- LINQ to Entities 不识别方法“System.Guid Parse(System.String)”,因此该方法无法转换为存储表达式。
LINQ to Entities 不识别方法"System.Guid Parse(System.String)",因此该方法无法转换为存储表达式. linq 中不能转换类型
- poj 1062 昂贵的聘礼 (最短路径)
昂贵的聘礼 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 33365 Accepted: 9500 Descriptio ...
- Linux下从零开始部署和使用Jaeger
最近在折腾Jaeger,Jaeger官网都是介绍如何通过Docker部署,二进制部署文档基本没有(已咨询过作者,作者说没文档!你参考Docker自己部署好了!!!),所以打算写一篇Linux部署. J ...
- BZOJ1017 [JSOI2008]魔兽地图DotR 【树形dp + 背包dp】
题目链接 BZOJ1017 题解 orz hzwer 树形dp神题 设\(f[i][j][k]\)表示\(i\)号物品恰好花费\(k\)金币,并将\(j\)个物品贡献给父亲的合成时的最大收益 计算\( ...