编程大赛-1
|
Electrons (ele)
|
Electrons are moving around in orbits whose radiuses are in the scope of positive integer. Two electrons moving in the same orbit after unavoidable collision combine into one and jump to the orbit whose radius is twice as large as the current orbit. Such process will be continuing until there are no more electrons sharing orbits. Calculate how many orbit will remain occupied at the end of the process.
Input:
Number of electrons n, 0 < n < 100000 is given at the first row of Second row contains npositive integers not greater then 2000 representing radius of orbit for each electron.
Output:
Number of occupied orbits should be printed at
Example:
For input data:
11
4 4 4 4 7 4 4 4 4 4 4
The correct answer ( result ) is:
3
|
Simultaneous processes (sim)
|
Having a list of all processes running in the system, determine the minimum and the maximum number of processes running simultaneously within a given time.
Task
Write a program which:
* accepts:
o a begin and end time in which the system is to be monitored
o number of processes and their run times
* determines the minimum number of processes that ran simultaneously.
* determines the maximum number of processes that ran simultaneously.
Input: (standard input)
+Line 1 of standard input contains two space-separated integers: b and e, 0 <= b <= e <= 1000000000. It is the beginning and the ending time when the system is to be monitored.
+Line 2 of standard input contains one integer n, where 1 <= n <= 10000. This is the number of all processes running in the system.
+Line i + 2, (where 1 <= i <= n) of standard input describes run time of i-th process. It contains two space-separated integers: pi and ki, where 0 <= pi <= ki <= 1000000000. These numbers denote that i-th process started at pi and ran till ki (inclusively).
Output: (standard output)
Your program should write two lines to standard output. The first line should contain the minimum number and the second line should contain the maximum number of processes running simultaneously between b and e (inclusively).
Example:
For sample input:
8 20
3
2 10
10 12
8 30
a correct output format:
1
3
|
Pixels (pix)
|
Suppose we have a simple process of generating pixels. We start from a pixel 0 at layer equal 0. Every second a next layer of pixels (children) is generated, a pixel p from the last layer l generates two pixels (children): 2 * p and 2 * p + 1 in a layer l + 1. Thus we have:
o layer 0: pixel 0,
o layer 1: pixels: 0, 1,
o layer 2: pixels: 0, 1, 2, 3,
o layer 3: pixels: 0, 1, 2, 3, 4, 5, 6, 7,
o
A pixel s, its children, children of its children, etc. are called descendants of s, and s is called their predecessor.
Task:
Write a program which:
o accepts a layer and some pixels from that layer,
o finds the greatest layer containing a predecessor of all read pixels.
Input: (standard input)
+Line 1 of standard input contains two space-separated integers: k and n, where 1 <= k<= 512, this is a layer, and 1 <= n <= 150 is a number of pixels from the given k-th layer.
+Line i + 1, (where 1 <= i <= n) of standard input specifies one pixel at the given k-th layer.
Output: (standard output)
Your program should write (to standard output) a single number that represents the greatest layer containing a predecessor of all read pixels.
Example:
For sample input:
3 3
0
3
2
a correct output format:
1

浙公网安备 33010602011771号