zoukankan      html  css  js  c++  java
  • NYOJ 86

     

    找球号(一)

    时间限制:3000 ms | 内存限制:65535 KB
    难度:3
     
    描述
    在某一国度里流行着一种游戏。游戏规则为:在一堆球中,每个球上都有一个整数编号i(0<=i<=100000000),编号可重复,现在说一个随机整数k(0<=k<=100000100),判断编号为k的球是否在这堆球中(存在为"YES",否则为"NO"),先答出者为胜。现在有一个人想玩玩这个游戏,但他又很懒。他希望你能帮助他取得胜利。
     
    输入
    第一行有两个整数m,n(0<=n<=100000,0<=m<=1000000);m表示这堆球里有m个球,n表示这个游戏进行n次。
    接下来输入m+n个整数,前m个分别表示这m个球的编号i,后n个分别表示每次游戏中的随机整数k
    输出
    输出"YES"或"NO"
    样例输入
    6 4
    23 34 46 768 343 343
    2 4 23 343
    
    样例输出
    NO
    NO
    YES
    YES
     1 //用map <int ,bool>也可 
     2 #include <iostream>
     3 #include <cstring>
     4 #include <bitset>
     5 using namespace std;
     6 
     7 bitset<100000110> Q;
     8 
     9 int main()
    10 {
    11      int i,j,k;
    12      Q.reset();
    13      int a,b,temp;
    14      cin>>a>>b;
    15      for(i=0;i<a;i++)
    16      {
    17           cin>>temp;
    18           Q.set(temp);
    19      }
    20      for(i=0;i<b;i++)
    21      {
    22           cin>>temp;
    23           if(Q.test(temp))
    24                cout<<"YES"<<endl;
    25           else
    26                cout<<"NO"<<endl;
    27      }
    28      return 0;
    29 }                
    30         
  • 相关阅读:
    poj 1860 Currency Exchange(最短路径的应用)
    poj 2965 The Pilots Brothers' refrigerator
    zoj 1827 the game of 31 (有限制的博弈论)
    poj 3295 Tautology (构造法)
    poj 1753 Flip Game(枚举)
    poj 2109 (贪心)
    poj 1328(贪心)
    Qt 对单个控件美化
    Qt 4基础
    Bash Shell
  • 原文地址:https://www.cnblogs.com/hxsyl/p/2677725.html
Copyright © 2011-2022 走看看