日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ZOJ18th省赛 Lucky 7

發(fā)布時間:2025/4/14 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ZOJ18th省赛 Lucky 7 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

[線上網(wǎng)址](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");} }

轉(zhuǎn)載于:https://www.cnblogs.com/Roni-i/p/8970899.html

總結(jié)

以上是生活随笔為你收集整理的ZOJ18th省赛 Lucky 7的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。