博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Uva 10474 Where is the Marble?
阅读量:6093 次
发布时间:2019-06-20

本文共 2428 字,大约阅读时间需要 8 分钟。

Where is the Marble?

 

  Where is the Marble? 

Raju and Meena love to play with Marbles. They have got a lot of marbles with numbers written on them. At the beginning, Raju would place the marbles one after another in ascending order of the numbers written on them. Then Meena would ask Raju to find the first marble with a certain number. She would count 1...2...3. Raju gets one point for correct answer, and Meena gets the point if Raju fails. After some fixed number of trials the game ends and the player with maximum points wins. Today it's your chance to play as Raju. Being the smart kid, you'd be taking the favor of a computer. But don't underestimate Meena, she had written a program to keep track how much time you're taking to give all the answers. So now you have to write a program, which will help you in your role as Raju.

 

Input 

There can be multiple test cases. Total no of test cases is less than 65. Each test case consists begins with 2 integers: N the number of marbles and Q the number of queries Mina would make. The next N lines would contain the numbers written on the N marbles. These marble numbers will not come in any particular order. Following Q lines will have Q queries. Be assured, none of the input numbers are greater than 10000 and none of them are negative.

Input is terminated by a test case where N = 0 and Q = 0.

 

Output 

For each test case output the serial number of the case.

For each of the queries, print one line of output. The format of this line will depend upon whether or not the query number is written upon any of the marbles. The two different formats are described below:

 

  • `x found at y', if the first marble with number x was found at position y. Positions are numbered 1, 2,..., N.
  • `x not found', if the marble with number x is not present.

Look at the output for sample input for details.

 

Sample Input 

4 1235155 213331230 0

 

Sample Output 

CASE# 1:5 found at 4CASE# 2:2 not found3 found at 3
1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 const int maxn=1000;15 using namespace std; 16 int main()17 {18 int n,q,x,a[maxn],kase=0;19 while(scanf("%d%d",&n,&q)==2&&n)20 {21 printf("CASE# %d:\n",++kase);22 for(int i=0;i
View Code

转载地址:http://mjlwa.baihongyu.com/

你可能感兴趣的文章
深度学习笔记之一些基本术语
查看>>
Highmaps网页图表教程之图表配置项结构与商业授权
查看>>
微信公众平台SDK for node
查看>>
Andrew Ng机器学习笔记+Weka相关算法实现(四)SVM和原始对偶问题
查看>>
使用Kotlin开发Android应用
查看>>
汽车行业品牌榜(2016年)--搜索指数
查看>>
Linux: su sudo sudoer
查看>>
错误:OSError: [Errno 1] Operation not permitted: 'lib/python/six-1.4.1-py2.7.egg-info'
查看>>
Jenkins构建脚本中启动tomcat关键
查看>>
Mac命令行启动MySQL
查看>>
MySql(七):MySQL性能调优——锁定机制与锁优化分析
查看>>
MySQL性能优化的最佳21条经验
查看>>
JS中的call、apply、bind
查看>>
SpringCloud如何配置Eureka授权
查看>>
【转】go语言的字节序
查看>>
Mysql系列一:SQL入门
查看>>
蔡文胜谈互联网变化
查看>>
SGU 208 Toral Tickets(polay计数)
查看>>
XML属性
查看>>
【MFC】序列化(Serialize)、反序列化(Deserialize)
查看>>