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 ...
随机推荐
- WordPress后台edit-tags.php里无限栏目分类实现
在 WordPress 里 http://localhost/wordpress3.6.1/wp-admin/edit-tags.php?taxonomy=category 这个链接可以显示 WP 里 ...
- Nginx的火速蔓延与其并发性处理优势
Nginx是俄罗斯人编写的十分轻量级的HTTP服务器.Nginx,它的发音为“engine X”, 是一个高性能的HTTP和反向代理服务器,同时也是一个IMAP/POP3/SMTP 代理服务器.Ngi ...
- codeforces 792CDivide by Three(两种方法:模拟、动态规划
传送门:https://codeforces.com/problemset/problem/792/C 题意:给你一个字符串,要求让你删除最少个数的元素,使得最终答案是没有前导0并且是3的倍数. 题解 ...
- codeforces 110E Lucky Tree
传送门:https://codeforces.com/contest/110/problem/E 题意:给你一颗树,节点与节点之间的边有一个边权,定义只由4和7组成的数字是幸运数字,现在要你求一共有多 ...
- 团队代码中Bug太多怎么办?怎样稳步提高团队的代码质量
最近负责的Android APP项目,由于团队成员变动.界面改版导致代码大幅修改等原因,产品发布后屡屡出现BUG导致的程序崩溃. 经过对异常统计和代码走读,BUG主要集中在空指针引起的NullPoin ...
- C++开源库,欢迎补充。
转载自:http://blog.csdn.net/kobejayandy/article/details/8681741 C++在"商业应用"方面,曾经是天下第一的开发语言,但这一 ...
- es6+最佳入门实践(7)
7.set和map数据结构 7.1.什么是set? Set就是集合,集合是由一组无序且唯一的项组成,在es6中新增了set这种数据结构,有点类似于数组,但是它的元素是唯一的,没有重复 let st = ...
- loj6100 「2017 山东二轮集训 Day1」第一题
传送门:https://loj.ac/problem/6100 [题解] 我们考虑维护从某个端点开始的最长满足条件的长度,如果知道了这个东西显然我们可以用主席树来对每个节点建棵关于右端点的权值线段树, ...
- bzoj 1066 最大流
将每个石柱拆成两个点,分别是进入的和出去的,两个点之间连石柱的高度 然后每个出去的点连别的石柱的进去的点, 源点连所有蜥蜴所在柱子,每个能跳出去的连汇点,然后最大流就行了 /************* ...
- 网络基础(osi、协议)
*互联网协议 人和人沟通需要一套共同的标准,英语就是普遍的一种,计算机如果需要进行联网互通,也需要一种统一的标准,如果所有的计算机都遵守这种标准,就会实现网络的互联. 1.一系列统一的标准,这些标准称 ...