题意:看代码

#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. HDU 6188:Duizi and Shunzi(贪心)(广西邀请赛)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6188 题意 有n个数字,每个数字小于等于n,两个相同的数字价值为1,三个连续的数字价值为1 .问这n个 ...

  2. hdu 5184 类卡特兰数+逆元

    BC # 32 1003 题意:定义了括号的合法排列方式,给出一个排列的前一段,问能组成多少种合法的排列. 这道题和鹏神研究卡特兰数的推导和在这题中的结论式的推导: 首先就是如何理解从题意演变到卡特兰 ...

  3. java时间处理--持续时间格式化工具和常量类DurationFormatUtils

    阅读目录 DurationFormatUtils类简介 maven地址 构造方法 DurationFormatUtils() formatDurationHMS(long durationMillis ...

  4. ES6必知必会 (三)—— 数组和对象的拓展

    数组的扩展 1.拓展运算符('...'),它相当于rest参数的逆运算,用于将一个数组转换为用逗号分隔的参数序列: console.log(...[1, 2, 3]) // 1 2 3 console ...

  5. day36 python学习gevent io 多路复用 socketserver *****

    ---恢复内容开始--- gevent 1.切换+保存状态 2.检测单线程下任务的IO,实现遇到IO自动切换 Gevent 是一个第三方库,可以轻松通过gevent实现并发同步或异步编程,在geven ...

  6. vue-cli 下的 webpack 优化

    app bundle 可以通过组件懒加载优化 vender 优化方法: 使用 cdn,然后在 webpack 配置中指定 externals. 利用 webpack 的插件 DllPlugin 和 D ...

  7. FineUI 选中多行获取行ID

    http://www.fineui.com/bbs/forum.php?mod=viewthread&tid=2506&page=1 /// <summary>       ...

  8. JMeter--使用URL回写来处理用户会话

    如果测试的Web应用系统使用URL回写而非Cookie来保存会话信息,那么测试人员需要做一些额外的工作来测试web站点 为了正确回应URL回写,JMeter需要解析从服务器收到的HTML,并得到唯一的 ...

  9. ES(6): access elasticsearch via curl

    curl是一个非常实用的.用来与服务器之间传输数据的工具:支持的协议包括 (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, ...

  10. 【python】copy浅拷贝和deepcopy深拷贝

    Python中的对象之间赋值时是按引用传递的,如果需要拷贝对象,需要使用标准库中的copy模块. 1. copy.copy 浅拷贝 只拷贝父对象,不会拷贝对象的内部的子对象. 2. copy.deep ...