zoukankan      html  css  js  c++  java
  • 2010 成都预选赛 Binary Number

    水题!可惜没看清当A中有多个相同结果时,要取最小值,被WA了一次。

    #include <iostream>
    using namespace std;

    int AC(int a,int b)
    {
         int n=0;
         while(a!=0||b!=0)
         {
                if(a%2!=b%2)
                n++;
                a/=2;
                b/=2;
         }
         return n;
    }
    int main()
    {
        int x,y,i,j,A[101],B[101],n,e,f,top;
        cin>>n;
        while(n--)
        {
                  cin>>x>>y;
                  for(i=0;i<x;i++)
                  cin>>A[i];
                  for(i=0;i<y;i++)
                 cin>>B[i];
                  for(i=0;i<y;i++)
                  {e=1000000;

                  for(j=0;j<x;j++)
                  {
                                  f=AC(A[j],B[i]);
                                  if(e>f)
                                  {
                                         top=A[j];
                                         e=f;
                                  }
                                  else if(e==f&&top>A[j])
                                  {
                                       top=A[j];
                                  }
                  }
                  cout << top<< endl;

                  }
        }   
     
    }
     

  • 相关阅读:
    postgresql批量插入copy_from()的使用
    Fabric SSH链接时关于找不到主机的问题
    Python多线程获取返回值
    网页正文提取,降噪的实现(readability/Document)
    HTML标签参考手册
    javascript获取当前日期和时间
    2017易观OLAP算法大赛
    Apache DolphinScheduler 诞生记
    Apache DolphinScheduler(海豚调度)
    开源分布式工作流任务调度系统Easy Scheduler Release 1.0.2发布
  • 原文地址:https://www.cnblogs.com/zxj015/p/2740299.html
Copyright © 2011-2022 走看看