zoukankan      html  css  js  c++  java
  • The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple

    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[5000000];
    int main()
    {
        std::ios::sync_with_stdio(false);
        int t;
        while(cin>>t){
            while(t--){
            int n,num;
            cin>>n>>num;
            int flag=0;
            for(int i=0;i<n;i++){
                    cin>>a[i];
            }
            for(int i=0;i<n;i++){
                    if((a[i]+num)%7==0){
                            flag=1;break;
                    }
            }
            if(flag)cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
        }
        return 0;
    }
  • 相关阅读:
    用户访问过的产品,在cookie记录产品id,id取得产品信息
    文件上传操作
    上次文件先创建目录,再上传到目录里面去
    解决PHPcms 2008 sp4 注册选择模型关闭后,注册不能自动登录的问题
    php输出表格的方法
    php中实现退后功能,不用历史记录
    PHP的substr_replace将指定两位置之间的字符替换为*号
    php算开始时间到过期时间的相隔的天数,同理可以实现相隔年,小时,分,秒等数
    不用js用php做tab选项卡
    再也回不去的从前
  • 原文地址:https://www.cnblogs.com/luowentao/p/8972793.html
Copyright © 2011-2022 走看看