31.07.2015 Views

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

8Task: Draw Koch’s QuadricIsland of the third degreeon the paper. Write an algorithmto draw Koch’s QuadricIsland of the n’th degree.Input is the degree of thecurve: an integer number n,1≤ n ≤ 8.Picture 184.2Picture 184.3If you do not have enough experience working with graphicsCopy the file EGVGA.BGI to your working folder. Your programmight look this way:program Koch;uses graph; { module graph will be used }procedure draw (n: integer);begin... { the code of the procedure }end; { draw }In order to draw the curve the followingfunctions and procedures of graph module mightbe useful.function GetMaxX: integer;{ returns the maximum available x coordinate }function GetMaxY: integer;{ returns the maximum available y coordinate }var n, { the degree of the curve }driver, { graphic driver }mode: integer; { graphic mode }beginreadln (n); { inputs the degree of the curve }{ automatic graphic driver detection }driver := detect;{ graphic mode initialization }InitGraph (driver, mode,'');draw (n); { call to curve drawing procedure }readln;CloseGraph; { back to the text mode }end.procedure line(x1, y1,x2, y2: integer);{ draws line from (x 1, y 1) to (x 2, y 2) }STAGE IIIJUNIOR DIVISION185. House Painting. The modern many-storeyed house is being built. It willhave n floors. The floors are counted starting from the first floor. Each floor will bepainted with one of the two colors: white or gray. Two consecutive floors can bewhite, but can’t be grayTask. Write a program to find the number many ways the n floor house can bepainted.ExampleInput data is number of floors of the house n (1 ≤ n ≤ 21)Input Outputgiven from the keyboard.Output (one integer number) should be printed to the screen. 3 5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!