库特选数。

库特有n个数,库特希望能从这n个数里选出来两个数,使他们的乘积为为m,请问库特能做到吗?如果存在库特能做到的方案,输出yes,否则输出no

Input

第一行两个数n ,m(2<=n<=1e5,0<=m<=1e9)
接下来一行n个数a[1]~a[n]。(0<=a[i]<=1e6)

Output

输出一行,yes或no
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
const int N=1e5+5;
typedef long long LL;
map<LL,int>vis;
LL a[N];
int main()
{
    LL n,m;
    while(cin>>n>>m)
    {

        int x,y,tmp,flag;
                flag=0;
        vis.clear();
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            x=a[i];
            vis[x]++;
        }
        if(m==0&&vis[0]>0){cout<<"yes"<<endl;continue;}
        if(m==0&&vis[0]==0){cout<<"no"<<endl;continue;}
        for(int i=0;i<n;i++)
        {
            if(a[i]!=0&&m%a[i]==0)
            {
                tmp=m/a[i];
                if(vis[tmp]>0&&tmp!=a[i])flag=1;
                if(vis[tmp]>1&&tmp==a[i])flag=1;
            }
        }
        if(flag==1)cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值