The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - M Lucky 7
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 ;
}
The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - M Lucky 7的更多相关文章
- The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - L Doki Doki Literature Club
Doki Doki Literature Club Time Limit: 1 Second Memory Limit: 65536 KB Doki Doki Literature Club ...
- 2018浙江省赛(ACM) The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple
我是铁牌选手 这次比赛非常得爆炸,可以说体验极差,是这辈子自己最脑残的事情之一. 天时,地利,人和一样没有,而且自己早早地就想好了甩锅的套路. 按理说不开K就不会这么惨了啊,而且自己也是毒,不知道段错 ...
- The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - J CONTINUE...?
CONTINUE...? Time Limit: 1 Second Memory Limit: 65536 KB Special Judge DreamGrid has clas ...
- The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - B King of Karaoke
King of Karaoke Time Limit: 1 Second Memory Limit: 65536 KB It's Karaoke time! DreamGrid is per ...
- The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple -A Peak
Peak Time Limit: 1 Second Memory Limit: 65536 KB A sequence of integers is called a peak, if ...
- ZOJ 4033 CONTINUE...?(The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple)
#include <iostream> #include <algorithm> using namespace std; ; int a[maxn]; int main(){ ...
- The 14th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - F 贪心+二分
Heap Partition Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge A sequence S = { ...
- The 14th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - C 暴力 STL
What Kind of Friends Are You? Time Limit: 1 Second Memory Limit: 65536 KB Japari Park is a larg ...
- ZOJ 3962 E.Seven Segment Display / The 14th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple E.数位dp
Seven Segment Display Time Limit: 1 Second Memory Limit: 65536 KB A seven segment display, or s ...
随机推荐
- Laravel中Redis的使用
安装 laravel中使用redis首先需要你通过 Composer 安装 predis/predis 包: composer require predis/predis 配置 redis的配置文件是 ...
- 【CF MEMSQL 3.0 D. Third Month Insanity】
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- 压缩跟踪Compressive Tracking
好了,学习了解了稀疏感知的理论知识后,终于可以来学习<Real-Time Compressive Tracking>这个paper介绍的感知跟踪算法了.自己英文水平有限,理解难免出错,还望 ...
- 2017年研究生数学建模D题(前景目标检测)相关论文与实验结果
一直都想参加下数学建模,通过几个月培训学到一些好的数学思想和方法,今年终于有时间有机会有队友一起参加了研究生数模,but,为啥今年说不培训直接参加国赛,泪目~_~~,然后比赛前也基本没看,直接硬刚.比 ...
- linux启动一个web项目时验证码不能出现的问题的解决
解决方法: 在tomcatcatalina.sh中搜索cygwin=false,然后在它的上面加上这句话JAVA_OPTS='-Djava.awt.headless=true' 具体参考如下图片: 然 ...
- 【hdu1712】分组背包(每组最多选1个)
[分组背包] [题意]ACboy要开始选课了,上一门课能够获得的收益和他上这门课的时间是有关的,然后给你若干门课,让你帮他进行选课,每一门课自然是只能选择一个课程时长,问你如何选择,才能使ACboy获 ...
- 【BZOJ】2442: [Usaco2011 Open]修剪草坪
[算法]动态规划 [题解] 万物皆动规,每时每刻都要想着DP!特别是这种明显可以序列递推的题目. 一个简单的思路是f[i]表示前i个选择合法方案(第i个可选可不选)的最大效率 f[i]=max(f[i ...
- 【洛谷 P1364】医院设置(树的重心)
树的重心的定义: 树若以某点为根,使得该树最大子树的结点数最小,那么这个点则为该树的重心,一棵树可能有多个重心. 树的重心的性质: 1.树上所有的点到树的重心的距离之和是最短的,如果有多个重心,那么总 ...
- DotNETCore 学习笔记 宿主
Hosting -------------------------------------------------------------------------- Setting up a Host ...
- bzoj 3223 裸splay
裸的splay 今儿写的splay,由于自己刚开始学,发现几个容易漏掉的地方 1:开始给所有的儿子赋值为-1 2:给max[-1]赋值为-maxlongint 3:开始father[root]:=sr ...