题意:看代码

#include<stdio.h>
#include<iostream>
#include<sstream>
#include<queue>
#include<map>
#include<memory.h>
#include <math.h>
#include<time.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
#define N 12000
int a[N];
int n, m; void sort()
{
for(int i = 0; i < n; i++)
for(int j = 1; j < n - i; j++)
if(a[j - 1] > a[j])
{
int t = a[j - 1];
a[j - 1] = a[j];
a[j] = t;
}
}
int find(int k)
{
for(int i = 0; i < n; i++)
{
if(!(a[i] ^ k))
return i;
}
return -1;
}
int sort(const void* a, const void* b)
{
int *pa = (int*) a;
int *pb = (int*) b;
return (*pa) - (*pb);
}
int main(const int argc, char** argv)
{
//freopen("d:\\1.txt", "r", stdin);
int t = 1;
while (scanf("%d %d", &n, &m))
{
if(m == n && n == 0)
return 0;
printf("CASE# %d:\n", t);
t++;
for(int i = 0; i < n; i++)
scanf("%d", a + i);
qsort(a, n, sizeof(int), sort);
int k = 0;
for(int i = 0; i < m; i++)
{
scanf("%d", &k);
int kk = -1;
if((-1 ^ (kk = find(k))))
{
printf("%d found at %d\n", k, kk + 1);
}
else
{
printf("%d not found\n", k);
}
}
} }

  冒泡排序。。。时间1.2s

快排。。。时间 390ms

uva-10474-枚举-水题的更多相关文章

  1. UVa 489 HangmanJudge --- 水题

    UVa 489 题目大意:计算机给定一个单词让你猜,你猜一个字母,若单词中存在你猜测的字母,则会显示出来,否则算出错, 你最多只能出错7次(第6次错还能继续猜,第7次错就算你失败),另注意猜一个已经猜 ...

  2. UVa 1585 Score --- 水题

    题目大意:给出一个由O和X组成的串(长度为1-80),统计得分. 每个O的分数为目前连续出现的O的个数,例如,OOXXOXXOOO的得分为1+2+0+0+1+0+0+1+2+3 解题思路:用一个变量t ...

  3. poj1873 The Fortified Forest 凸包+枚举 水题

    /* poj1873 The Fortified Forest 凸包+枚举 水题 用小树林的木头给小树林围一个围墙 每棵树都有价值 求消耗价值最低的做法,输出被砍伐的树的编号和剩余的木料 若砍伐价值相 ...

  4. UVA 11636-Hello World!(水题,猜结论)

    UVA11636-Hello World! Time limit: 1.000 seconds When you first made the computer to print the sentenc ...

  5. HDU 1017 A Mathematical Curiosity (枚举水题)

    Problem Description Given two integers n and m, count the number of pairs of integers (a,b) such tha ...

  6. COGS 1406. 邻居年龄排序[Age Sort,UVa 11462](水题日常)

    ★   输入文件:AgeSort.in   输出文件:AgeSort.out   简单对比时间限制:1 s   内存限制:2 MB [题目描述] Mr.Zero(CH)喜闻乐见地得到了一台内存大大增强 ...

  7. CodeForces 444C. DZY Loves Physics(枚举+水题)

    转载请注明出处:http://blog.csdn.net/u012860063/article/details/37509207 题目链接:http://codeforces.com/contest/ ...

  8. 方程的解——枚举&&水题

    题目 链接 给出方程组:$$\displaystyle \left\{\begin{aligned}11x + 13y + 17z = 2471 \\13x + 17y + 11z = 2739\en ...

  9. zoj 3809 枚举水题 (2014牡丹江网赛 A题)

    题目大意:给出一列取样的几个山的高度点,求山峰有几个? Sample Input 291 3 2 4 6 3 2 3 151 2 3 4 5Sample Output 30 # include < ...

  10. UVa 12342 Tax Calculator (水题,纳税)

    今天在uva看到一个水题,分享一下. 题意:制定纳税的总额,有几个要求,如果第一个180000,不纳,下一个300000,纳10%,再一个400000,纳15%,再一个300000,纳20%,以后的纳 ...

随机推荐

  1. MP算法、OMP算法及其在人脸识别的应用

    主要内容: 1.MP算法 2.OMP算法 3.OMP算法的matlab实现 4.OMP在压缩感知和人脸识别的应用 一.MP(Matching Pursuits)与OMP(Orthogonal Matc ...

  2. HPU 1166: 阶乘问题(一)

    1166: 阶乘问题(一) [数学] 时间限制: 1 Sec 内存限制: 128 MB提交: 58 解决: 24 统计 题目描述 小H对阶乘!很感兴趣.现在他想知道N!N!的位数,由于NN太大了,所以 ...

  3. React中如何优雅的捕捉事件错误

    React中如何优雅的捕捉事件错误 前话 人无完人,所以代码总会出错,出错并不可怕,关键是怎么处理. 我就想问问大家react的错误怎么捕捉呢? 这个时候: 小白:怎么处理? 小白+: ErrorBo ...

  4. test20180919 选择客栈

    题意 分析 不难发现把增加人数看成减少人数,上限是w 看成总数是w,问题就变成了询问有多少个子区间没有0. 考虑这个问题困难在哪里,就是区间加减法让我们不好判断0 的位置. 因为题目保证每个位置的值非 ...

  5. day 2 Linux Shell笔记

    ------------------------------------------------------------------- -------------------------------- ...

  6. 使用MVC5的Entity Framework 6入门 ---- 系列教程

    使用MVC5的Entity Framework 6入门(十二)——为ASP.NET MVC应用程序使用高级功能 为ASP.NET MVC应用程序使用高级功能这是微软官方教程Getting Starte ...

  7. TNS-12535 TNS-00505的处理方法

    原文地址:TNS-12535 TNS-00505的处理方法 作者:wzq609 硬件说明: 操作系统版本:ORACLE LINUX 6.3  64位 数据库版本:11.2.0.3   64位 问题说明 ...

  8. c 结构体的队列

    头文件 lsg_queue.h #pragma once #include<stdbool.h> /* 链式栈接口的定义头文件 */ #define true 1 #define fals ...

  9. redux学习与使用

    Redux: 主要概念Action,reducer,store,state 原理:dispatch ({ type:action, preload: { val } } ) --->reduce ...

  10. golang channel 的使用

    本文对channel使用中的几个疑惑,以例子的形式加以说明. 普通channel 缺省情况下,发送和接收会一直阻塞着,直到另一方准备好. 例如: package main import ( " ...