参考:https://blog.csdn.net/q547550831/article/details/51326321

 #include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 10000
int main()
{
int n,q,count=; while (scanf("%d %d",&n,&q)!=EOF)
{
if (n==&&q==)
{
break;
}
int m[N];
int i;
for (i=;i<n;i++)
{
scanf("%d",&m[i]);
}
sort(m,m+n);
printf("CASE# %d:\n",++count);//此行要放在while前面!!!
while (q--)
{
int temp;
scanf("%d",&temp);
int t=lower_bound(m,m+n,temp)-m;
if (m[t]==temp)
{
printf("%d found at %d\n",temp,t+);
}
else
{
printf("%d not found\n",temp);
}
}
} return ;
}

UVA10474 Where is the Marble?【排序】的更多相关文章

  1. UVa10474 Where is the Marble?(排序sort)

    今天开始学STL,这是书上的一道例题,主要是用了sort函数和lower_bound函数,挺容易理解的. lower_bound的作用是查找“大于或等于x的第一个位置”. 需要注意的是,不要忘记alg ...

  2. UVA.10474 Where is the Marble ( 排序 二分查找 )

    UVA.10474 Where is the Marble ( 排序 二分查找 ) 题意分析 大水题一道.排序好找到第一个目标数字的位置,返回其下标即可.暴力可过,强行写了一发BS,发现错误百出.应了 ...

  3. Uva10474 - Where is the Marble?

      两种解法: 1.计数排序 //计数排序 #include<cstdio> #include<iostream> #include<vector> #includ ...

  4. 10474 - Where is the Marble?(模拟)

    传送门: UVa10474 - Where is the Marble? Raju and Meena love to play with Marbles. They have got a lot o ...

  5. 排序与检索【UVa10474】Where is the Marble?

    Where is the Marble?  DescriptionRaju and Meena love to play with Marbles. They have got a lot of ma ...

  6. 【UVA - 10474 】Where is the Marble?(排序)

    Where is the Marble? Descriptions: Raju and Meena love to play with Marbles. They have got a lot of ...

  7. uva 10474 Where is the Marble? 计数排序

    题目给出一系列数字,然后问哪个数字是从小到大排在第几的,重复出现算第一个. 数据范围为10000,不大,完全可以暴力,sort不会超时. 但是由于以前做比赛时也遇到这种题目,没注意看数据范围,然后暴力 ...

  8. Problem A Where is the Marble?(查找排序)

    题目链接:Problem A 题意:有n块大理石,每个大理石上写着一个非负数,首先把数从小到大排序,接下来有Q个问题,每个问题是是否有某个大理石上写着x,如果有,则输出对应的大理石编号. 思路:先排序 ...

  9. 5_1 大理石在哪儿(UVa10474)<排序与查找>

    Raju和Meena喜欢玩弹珠,他们有许多上面有号码的弹珠.一开始时,Raju按照弹珠上面的号码由小到大排成一列,然后Meena会要求Raju找出某个号码的第一颗弹珠所在的位置.她会算1…2…3…,如 ...

随机推荐

  1. java实现多文件上传01

    1.html代码 <html> <head> <link rel="stylesheet" type="text/css" hre ...

  2. Struts的学习-配置

    1.进入官网http://struts.apache.org/download.cgi#struts2513,这里为下载地址,(ps:struts-2.5.13-all版本). 2.将..\strut ...

  3. Jerry的CRM Middleware(中间件)文章合集

    我在SAP成都研究院做过的CRM中间件的项目其实并不是很多: 1. 2013年下半年和2014年上半年曾经支持过中联重科和蒙牛的CRM项目相关的中间件问题; 2. 2014年上半年做过一个CRM物料主 ...

  4. python接口测试-项目实践(七)脚本优化

    七 脚本优化:重复代码的提取成函数:与项目接口相关的都封装到一个类中:添加手工验证脚本,增加输入值的判断逻辑 将所有与该项目接口相关的封装成类 class ProjectApi: #3个数据源接口 d ...

  5. Django运行访问项目出现的问题:Invalid HTTP_HOST header: '192.168.114.25:8001'. You may need to add u'192.168.114.25' to ALLOWED_HOSTS.

    当运行python manage.py runserver 0.0.0.0:8001时候,出现Invalid HTTP_HOST header: '192.168.114.25:8001'. You ...

  6. POJ 3321 Apple Tree 【树状数组+建树】

    题目链接:http://poj.org/problem?id=3321 Apple Tree Time Limit: 2000MS Memory Limit: 65536K Total Submiss ...

  7. HashMap中的equals和hashCode

    HashMap的存储方式 HashMap的实现方式是数组链,不同的对象根据其哈希码(hashCode方法的返回值)找到对应的数组下标,然后存入数组.不同的对象有相同的哈希码时怎么办?这就由数组链中的链 ...

  8. maven学习记录三——maven整合ssh框架

    6       整合ssh框架 6.1     依赖传递 只添加了一个struts2-core依赖,发现项目中出现了很多jar, 这种情况 叫 依赖传递 6.2     依赖版本冲突的解决 1.  第 ...

  9. 数字图像处理学习笔记之一 DIP绪论与MATLAB基础

    写在前面的话 数字图像处理系列的学习笔记是作者结合上海大学计算机学院<数字图像处理>课程的学习所做的笔记,使用参考书籍为<冈萨雷斯数字图像处理(第二版)(MATLAB版)>,同 ...

  10. 使用TextView/EditText应该注意的地方,监听EditText,addTextChangedListener

    http://blog.csdn.net/huichengongzi/article/details/7818676 监听 EditText 控件: addTextChangedListener(ne ...