zoukankan      html  css  js  c++  java
  • NYOJ-626-intersection set(二分查找)

     题目链接

     1 /*
     2     Name:NYOJ-626-intersection set
     3     Copyright:
     4     Author:
     5     Date: 2018/4/12 21:30:10
     6     Description:
     7     二分查找水题 
     8 */
     9 #include <iostream>
    10 #include <algorithm> 
    11 #include <set>
    12 #include <cstdio>
    13 using namespace std;
    14 int nums1[50005], nums2[50005];
    15 int main()
    16 {
    17     ios::sync_with_stdio(false);
    18     int m, n;
    19     while (~scanf("%d %d", &m,&n)) {
    20         int tmp;
    21         for (int i=0; i<m; i++) {
    22             scanf("%d", &nums1[i]);
    23         }
    24         for (int i=0; i<n; i++) {
    25             scanf("%d", &nums2[i]);
    26         }
    27         sort(nums1, nums1+m);
    28         sort(nums2, nums2+n);
    29         int ct = 0;
    30         for (int i=0; i<m; i++) {
    31             if (binary_search(nums2, nums2+n, nums1[i]) == true) {
    32                 ct++;
    33             }
    34         }
    35         printf("%d
    ", ct);
    36     }
    37     return 0;
    38 }
  • 相关阅读:
    Maven ==> 简介
    IDEA结合GIT的使用
    Shell ==> 基础
    Dubbo ==> 简介
    iptables防火墙
    文件系统对比
    supervisord部署
    inotify+rsync安装配置
    前端插件网址
    Nginx高级玩法
  • 原文地址:https://www.cnblogs.com/slothrbk/p/8810645.html
Copyright © 2011-2022 走看看