473,395 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Counting Quadrangles

Description
a hero invented a new style of cross-bow that could shoot
consecutively. The arrow could hit the eagle exactly if only the arrow
could reach the height of the eagle. However, there was a flaw of the
corss-bow: only the first arrow could reach any height and the height
that the arrow shot latter could reach was always lower than the
former one. Actually, the higher the cross-bow can hit, the better the
performance it is. One day, the hero happened to see a crowd of eagles
flying through the sky. Now you have to work out a program that helps
Guo Jing to count how many eagles he can shoot down at most.
Input
This problem contains multiple test cases. For each test case, input
the number of eagles n (1<=n<=1000) in the first line, then input the
height h of each eagle (1<=h<=10000) in another new line with a blank
between every two of them.
Output
Please calculate the maximal number of eagles m that can be shot down
by the cross-bow in the first line, and then output the height of the
each eagle that have been shot down and separated by blanks in the
second line.
Sample Input
8
389 207 155 300 299 170 158 65
2
100 105

Sample Output
6
389 300 299 170 158 65
1
105

Oct 14 '07 #1
2 1337
ch********@gmail.com wrote:

[something that looked like a homework assignment]

And your C question is...?
Oct 14 '07 #2

<ch********@gmail.comwrote in message
news:11**********************@i38g2000prf.googlegr oups.com...
Description
a hero invented a new style of cross-bow that could shoot
consecutively. The arrow could hit the eagle exactly if only the arrow
could reach the height of the eagle. However, there was a flaw of the
corss-bow: only the first arrow could reach any height and the height
that the arrow shot latter could reach was always lower than the
former one. Actually, the higher the cross-bow can hit, the better the
performance it is. One day, the hero happened to see a crowd of eagles
flying through the sky. Now you have to work out a program that helps
Guo Jing to count how many eagles he can shoot down at most.
Input
This problem contains multiple test cases. For each test case, input
the number of eagles n (1<=n<=1000) in the first line, then input the
height h of each eagle (1<=h<=10000) in another new line with a blank
between every two of them.
Output
Please calculate the maximal number of eagles m that can be shot down
by the cross-bow in the first line, and then output the height of the
each eagle that have been shot down and separated by blanks in the
second line.
Sample Input
8
389 207 155 300 299 170 158 65
2
100 105

Sample Output
6
389 300 299 170 158 65
1
105
Hint.
Think what to do if you have one eagle left. The two, then three, then four.
Work backwards until you decide whether to shoot the first eagle or not.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Oct 14 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Elbert Lev | last post by:
Please correct me if I'm wrong. Python (as I understand) uses reference counting to determine when to delete the object. As soon as the object goes out of the scope it is deleted. Python does...
1
by: ash | last post by:
hi does anyone has any experience with flyweight pattern with refernce counting i want to share objects between multiple clients and want to delete the object from shared pool when the last...
1
by: Tony Johansson | last post by:
Hello Experts! I reading a book called programming with design pattern revealed by Tomasz Muldner and here I read something that I don't understand completely. It says "A garbarage...
1
by: Tony Johansson | last post by:
Hello Experts! I reading a book called programming with design pattern revealed by Tomasz Muldner and here I read something that I don't understand completely. It says "A garbarage...
18
by: ChadDiesel | last post by:
I appreciate the help on this group. I know I've posted a lot here the last couple of weeks, but I was thrown into a database project at my work with very little Access experience. No other...
7
by: zets | last post by:
I need a macro for counting the bits in the odd positions of a given input (of any type, char, pointer, int, struct, whatever). Is there any clever way I could not think of, to do it efficiently? ...
1
by: j | last post by:
Hi, I've been trying to do line/character counts on documents that are being uploaded. As well as the "counting" I also have to remove certain sections from the file. So, firstly I was working...
4
by: aaronfude | last post by:
Hi, Please consider the following class (it's not really my class, but it's a good example for my question): class Vector { int myN; double *myX; Vector(int n) : myN(n), myX(new double) { }...
1
by: oec.deepak | last post by:
Hi Cn any one telll me what is Reference counting in C++.
3
by: nitric | last post by:
hey guys, i'm really stuck on this program. It's basically a survey and I have to ask people what drinks they like. 1-4, coffee tea oj and lemonade. i'm having trouble counting the TOTAL NUMBER...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.