uva 10474 Where is the Marble?(大理石在哪儿)
来源:互联网 发布:财务自由之路 知乎 编辑:程序博客网 时间:2024/05/01 07:02
题目大意:
有n个大理石,每个大理石上写一个非负整数,首先把各数按照从小到大排序,问Q个问题每个问题问是否一个大理石写着一个数X,如果有,回答那个大理石写着X。
题解:
就排序查找就行,我觉得二分更快,懒得写0.0,
#include<stdio.h>#include<algorithm>using namespace std;const int maxn=10000000;int a[maxn];int main(){int x,y;int T=1;while(~scanf("%d%d",&x,&y)&&x&&y){ printf("CASE# %d:\n",T++);for(int i=0;i<x;i++){scanf("%d",&a[i]);}sort(a,a+x);for(int i=0;i<y;i++){ int flag=0;int t;scanf("%d",&t);int j;for(j=0;j<x;j++){if(a[j]==t){ printf("%d found at %d\n",t,j+1); flag=1; break;}}if(flag==0) printf("%d not found\n",t);}}return 0;}
0 0
- UVa 10474 Where is the Marble?(大理石在哪儿)
- uva 10474 Where is the Marble?(大理石在哪儿)
- 大理石在哪儿(Where is the marble?,UVa 10474)
- uva10474大理石在哪儿where is the marble?
- 大理石在哪儿 where is the Marble? lower_bound()
- 大理石在哪儿 where is the Marble?
- 10474 - 大理石在哪儿Where is the Marble?(排序+检索)
- 大理石在哪(Where is the Marble?, uva 10474)
- 《算法竞赛入门经典2ndEdition 》例题5-1 大理石在哪儿(Where is the marble?, Uva10474)
- 大理石在哪?(Where is the Marble?, UVa 10474)代码
- 例题5-1 UVA 10474 Where is the Marble?大理石在哪?
- UVa 10474 Where is the Marble?
- Uva 10474 Where is the Marble?
- uva 10474 Where is the Marble?
- UVA 10474 Where is the Marble?
- UVA 10474 - Where is the Marble
- uva-10474 - Where is the Marble?
- uva 10474 - Where is the Marble?
- 驱动内存映射文件
- 路障(广度优先搜索)
- linux命令--查看是否装有数据库
- 2016.09.24【初中部 NOIP提高组 】模拟赛C
- COOKIE和SESSION有什么区别
- uva 10474 Where is the Marble?(大理石在哪儿)
- 【POJ 3371】Flesch Reading Ease
- CSS实战技巧:大小不固定,多行文字的垂直居中
- Linux的权限操作
- Java集合(二)
- Android开发入门经典实例
- 深度相机(四)--Realsense概览
- 用Word2vec训练中文wiki,构造词向量并做词聚类
- ModelAndView跳转