题意:看代码

#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. 轻松制作儿童趣味算术软件 - imsoft.cnblogs

    轻松制作儿童趣味算术软件 马震安 电脑爱好者 2014-07-23 08:38技巧 0 条评论 标签:软件   兴趣是学习的动力,以动感的软件和自动判断得分的形式测试孩子的算术能力,总要比在白纸上出几 ...

  2. 使用struts框架后的404错误

    访问jsp界面后出现404错误,我开始以为是因为struts没有配置好,在网上找了很多解决方法, 试了一遍,无效, 最后在参考书上看到“struts2推荐把所有的视图界面存放在WEB-INF目录下,这 ...

  3. 大家一起做训练 第一场 G CD

    题目来源:UVA 624 题目的意思就是:我现在需要从 t 张CD中拿出一部分来,尽可能的凑出接近 N 这么久的音乐,但是不能超过 N. CD不超过20张,每张长度不超过 N ,不能重复选. 一个很简 ...

  4. CTF密码学之凯撒加密

    在加密的各种算法中,凯撒加密是最简单的也是最常见的一种加密方法,它的中心思想是替换,ROT加密其实就是凯斯加密的变种. 即明文的所有字母都在字母表上向后(或向前)按照一个固定数目进行偏移后被替换成密文 ...

  5. frameset的用法

    碰到一个frameset的问题,因为我比较懒,就先从网上拿来一篇基础知识,呵呵,好记性不如烂笔头啊        所谓框架便是网页画面分成几个框窗,同时取得多个 URL.只需要 <FRAMESE ...

  6. sys目录下常用文件汇总

    1. /sys/kernel/debug/gpio 可以实时反馈系统中感兴趣的gpio引脚的状态 root@g6s:/sys/kernel/debug# cat gpio gpiochip7: GPI ...

  7. MySQL--Delete语句别名+LIMIT

    在MySQL中,可以使用LIMIT来限制删除的数量,但部分写法并不支持LIMIT. LIMIT方式 对于查询: ; 可以转换成: ; 别名方式: ## 使用别名 DELETE T FROM T1 AS ...

  8. TFTP error: 'Only absolute filenames allowed' (2)

    hisilicon # tftp 0x82000000 u-boot-hi3518ev200.bin Hisilicon ETH net controler MAC: ----- eth0 : phy ...

  9. MapReduce-皮尔逊(Pearson)线性相关

    Pearson相关系数解决了两个群的数据是否线性相关的问题: 先补充一下基本概念: 协方差:如果两个变量的变化趋势一致,也就是说如果其中一个大于自身的期望值时另外一个也大于自身的期望值,那么两个变量之 ...

  10. FineUI Grid中WindowField根据列数据决定是否Enalble

    前台页面Grid控件中设置OnPreRowDataBound属性,windowFile控件设置ID protected void Grid1_PreRowDataBound(object sender ...