(acm) سوالات زير از مسابقات جهاني مي باشد

Back           Next

                                             نمونه سوال  
   

   program 1

source file : *.c/cpp/java

A junior high school has found that many of their students have problems with the conceptualisation of mathematical expressions evaluated in postfix. You were contacted by the school to develop a program that could evaluate expressions in postfix, so that the students can practice with it helping them to keep the objectives of the class.

The program was requested by the professor of Mathematics I. For this reason the program should only handle operations with two operands and one operator, real numbers and the four basic operations: addition, subtraction, multiplication and division. An addition request was made. The program could only remember two operands.

INPUT
The input of the program will be a text file containing the data for several runs. Each line will have one expression. Each expression will have a valid structure. Each line could be up to 100 characters.  The program should stop after processing all the expressions.
 

OUTPUT
The output is a text file. In this file you have to show the result of each expression, one result per line. It should have a four digit precision.

SAMPLE INPUT FILE
123 1254 + 1.254 * 45.87 /
5 4 +
5 4 + 1 + 2 + 12 -
3 2 * 1 - 2 / 3.1415 +
 

SAMPLE OUTPUT FILE
37.6446
9
0
5.6415
 


    program 2

source file : *.c/cpp/java

Anthrax, also called Splenic Fever, Malignant Pustule, or Woolsorters' Disease, is caused by Bacillus anthracis, an organism that under certain conditions forms highly resistant spores capable of maintaining its virulent effect for many years in contaminated soil and other materials.

Anthrax was the first human disease that was demonstrated to be caused by a specific microrganism. It was also the first infectious disease against which a bacterial vaccine was found to be effective (Louis Pasteur in 1881). These discoveries led to the origin and development of bacteriology and immunology.

Interest has reborn around the study of how infected cells reproduce and die. A hypothesis states that cell reproduction can be modelled as a two-dimensional infinite grid of square cells like chessboard cells but in Practical lab studies its defined as finite grid.  In this grid, each cell is considered to be alive or dead. A living cell is represented as a mark on its position in the grid.  Each cell has up to 8 neighbouring cells (up, down, left, right, upper-right, upper-left, lower-right and lower-left). Cells located in the border of the grid have smaller number of neighbours.

The model starts with an Initial Generation (G0) consisting of some living and death cells in the Grid.  After reproduction rules are applied to every Cell, a new Generation G1 is obtained. New generations are always created using the information of the previous generation.  That is Generation Gi is created based on information of Generation Gi-1

The reproduction rules that are used in the model are:

1.A dead cell with exactly three living neighbours becomes a living cell (birth).
2.A living cell with cero or one living neighbours dies (loneliness).
3.A living cell with two or three living neighbours stays alive (survival).
4.A living cell with four or more living neighbours dies (overcrowding).

In all other cases, a cell dies. Existing death cells remain death (overcrowding or loneliness).
 

EXAMPLES.
This initial generation will evolve in a generation where all cells die.
 
 

 This initial generation yields generations that will always be the same as the initial.
 
 
 

If the initial generation is    the next generation will be    the following  generations will be alternating between these two generations.

In more complex cases, it is impossible to look at a starting position (or pattern) and see what will happen in the future. The only way to find out is to follow the rules

INPUT
The input of the program will be a text file, (located in the same path as the executable).  The input will contain data for several runs, each run will have the following information:

The first line has two numbers indicating the X and Y dimensions of the grid. (X number of columns, Y number of rows).  A 0 in this first line indicates end of run.
The second line is one number representing the number of generations that must be obtained.
The third line is a number, that specifies the number of cells that have a microrganism.
Starting in the forth line, there will be the coordinates of each microrganism, one per line with format x, y (x is column number and y is row number). The row and column numbers start at 1.

OUTPUT
The output is a text file (located in the same path that the program). In this file you have to show the different generations starting with the Initial Generation. A Generation is represented as a matrix showing Living microrganisms as an "*" (asterisk) and death cells as a "0" (cero).

Before printing the Initial Generation you should output the study number. Before the Initial Generation write the string "Initial Generation". Before each new generation write "Generation x", where "x" is the generation number.

SAMPLE INPUT FILE
15 10
5
3
5 5
5 6
5 7
0

SAMPLE OUTPUT FILE
Study 1
Initial Generation
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 * 0 0 0 0 0 0 0 0 0 0
0 0 0 0 * 0 0 0 0 0 0 0 0 0 0
0 0 0 0 * 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Generation 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 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