码迷,mamicode.com
首页 > 其他好文 > 详细

[FAFU 1266]STL排序+二分查找

时间:2014-09-16 10:36:10      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   ar   for   div   sp   log   c   

http://acm.fafu.edu.cn/problem.php?id=1266

 

思路很容易理解:

#include<cstdio>
#include<algorithm>
using namespace std;
int num[1000000];
int main()
{
    int n,m,a;
    while(~scanf("%d",&n))
    {
        for(int i=0;i<n;++i)
        {
            scanf("%d",&num[i]);
        }
        scanf("%d",&m);
        sort(num,num+n);
        for(int i=0;i<m;++i)
        {
            if(i) putchar(‘ ‘);
            scanf("%d",&a);
            printf("%d",upper_bound(num,num+n,a)-lower_bound(num,num+n,a));
        }
        putchar(‘\n‘);
    }
    return 0;
}

  

[FAFU 1266]STL排序+二分查找

标签:blog   http   io   ar   for   div   sp   log   c   

原文地址:http://www.cnblogs.com/WanBOSS/p/3974334.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!