Fipi computer science exam with detailed solution. B20: cycles and conditions. Structure of KIM Unified State Examination

Unified State Exam decision Informatics

1. Task. How many ones are in the binary notation of the hexadecimal number 12F0 16 ?

Explanation.

Let's convert the number 12F0 16 to binary number system: 12F0 16 = 1001011110000 2 .

Let's count the number of units: there are 6.

Answer: 6.

2. Task Logic function F is given by the expression (¬ z ) ∧ x ∨ x ∧ y . Determine which column of the function's truth table F each of the variables corresponds x, y, z.

AC 1

AC 2

AC 3

Function

Write the letters in your answer x, y, z in the order in which their corresponding columns appear (first - the letter corresponding to the 1st column; then - the letter corresponding to the 2nd column; then - the letter corresponding to the 3rd column). Write the letters in the answer in a row; there is no need to put any separators between the letters. Example. Let the expression be given x → y , depending on two variables x and y , and the truth table:

AC 1

AC 2

Function

Then the 1st column corresponds to the variable y , and the 2nd column corresponds to the variable x . In your answer you need to write: yx.

Explanation.

This expression is a disjunction of two conjunctions. We can notice that both terms have a multiplier x. That is, at x = 0 the sum will be equal to 0. So, for the variable x Only the third column is suitable.

In the eighth row of the table x = 1, and the function value is 0. This is only possible if z = 1, y = 0, i.e. variable1 − z , and variable2 − y.

Answer: zyx.

3. Task In the figure on the right, the road map of the N district is depicted in the form of a graph; the table contains information about the lengths of these roads (in kilometers).

Since the table and diagram were drawn independently of each other, the numbering settlements in the table is in no way related to letter designations on the graph. Determine the length of the road from point B to point E. Write down an integer in your answer - as it is indicated in the table.

Explanation.

Point B is the only point with five roads, which means P6 corresponds to it, and point E is the only point with four roads, which means P4 corresponds to it.

The length of the road from P6 to P4 is 20.

Answer: 20.

4. Task A fragment of the database provides information about family relationships. Based on the given data, determine how many direct descendants (i.e. children and grandchildren) of Pavlenko A.K. are mentioned in Table 1.

Table 1

Last name_I.O.

Floor

2146

Krivich L.P.

2155

Pavlenko A.K.

2431

Khitruk P. A.

2480

Krivich A. A.

2302

Pavlenko E. A.

2500

Sokol N. A.

3002

Pavlenko I. A.

2523

Pavlenko T. Kh.

2529

Khitruk A.P.

2570

Pavlenko P. I.

2586

Pavlenko T. I.

2933

Simonyan A. A.

2511

Sokol V. A.

3193

Biba S. A.

table 2

Parent ID

ID_Child

2146

2302

2146

3002

2155

2302

2155

3002

2302

2431

2302

2511

2302

3193

3002

2586

3002

2570

2523

2586

2523

2570

2529

2431

2529

2511

2529

3193

OR

For group operations with files, file name masks are used. The mask is a sequence of letters, numbers and other characters allowed in file names, which may also contain the following characters:

Symbol "?" (question mark) means exactly one arbitrary character.

The symbol “*” (asterisk) means any sequence of characters of arbitrary length, including “*” can also specify an empty sequence.

There are 6 files in the directory:

maveric.map

maveric.mp3

taverna.mp4

revolver.mp4

vera.mp3

zveri.mp3

Below are eight masks. How many of them are there that correspond to exactly four files from a given directory?

*ver*.mp*

*?ver?*.mp?

?*ver*.mp?*

*v*r*?.m?p*

???*???.mp*

???*???.m*

*a*.*a*

*a*.*p*

Explanation.

From Table 2 we see that Pavlenko A.K. (ID 2155) has two children, their IDs: 2302 and 3002.

Pavlenko E. A. (ID 2302) has three children, and Pavlenko I. A. (ID 3002) has two.

Thus, Pavlenko A.K. has seven direct descendants: two children and five grandchildren.

Answer: 7.

OR

Let's look at each mask:

1. Five files will be selected based on the mask *ver*.mp*:

maveric.mp3

taverna.mp4

revolver.mp4

vera.mp3

zveri.mp3

2. By mask *?ver?*.mp? three files will be selected:

maveric.mp3

taverna.mp4

zveri.mp3

3. By mask?*ver*.mp?* four files will be selected:

maveric.mp3

taverna.mp4

revolver.mp4

zveri.mp3

4. One file will be selected based on the mask *v*r*?.m?p*:

maveric.map

5. Three files will be selected based on the mask???*???.mp*:

maveric.mp3

taverna.mp4

revolver.mp4

6. Four files will be selected based on the mask???*???.m*:

maveric.map

maveric.mp3

taverna.mp4

revolver.mp4

7. One file will be selected using the mask *a*.*a*:

maveric.map

8. Four files will be selected based on the mask *a*.*p*:

maveric.map

maveric.mp3

taverna.mp4

vera.mp3

That is, three masks that correspond to exactly four files from a given directory.

Answer: 3.

Answer: 7|3

5. Task Messages containing only four letters are transmitted through the communication channel: P, O, S, T; For transmission, a binary code is used that allows unambiguous decoding. For the letters T, O, P, the following code words are used: T: 111, O: 0, P: 100.

Specify the shortest code word for the letter C, at which the code will allow unambiguous decoding. If there are several such codes, indicate the code with the lowest numerical value.

Explanation.

The letter C cannot be encoded as 0, since 0 is already taken.

The letter C cannot be encoded as 1, since the encoding of the letter T begins with 1.

The letter C cannot be encoded as 10, since the encoding of the letter P begins with 10.

The letter C cannot be encoded as 11, since the encoding of the letter T begins with 11.

The letter C can be coded as 101, which is the smallest possible value.

Answer: 101.

6. Task The input of the algorithm is a natural number N. The algorithm constructs a new number R from it as follows.

1. A binary representation of the number N is constructed.

2. Two more digits are added to this entry on the right according to the following rule:

A) all the digits of the binary notation are added, and the remainder of dividing the sum by 2 is added to the end of the number (on the right). For example, record 11100 is converted to record 111001;

B) the same actions are performed on this entry - the remainder of dividing the sum of digits by 2 is added to the right.

The record obtained in this way (it has two digits more than in the record of the original number N) is a binary record of the desired number R.

Indicate the smallest number N for which the result of the algorithm is greater than 125. In your answer, write this number in decimal system Reckoning.

OR

The Calculator performer has two teams, which are assigned numbers:

1. add 2,

2. multiply by 5.

By performing the first of them, the Calculator adds 2 to the number on the screen, and by performing the second, it multiplies it by 5.

For example, program 2121 is a program

multiply by 5,

add 2,

multiply by 5,

add 2,

which converts the number 1 to the number 37.

Write down the order of commands in a program that converts the number 2 to the number 24 and contains no more than four commands. Enter only command numbers.

Explanation.

This algorithm adds either 10 to the end of the number if its binary notation initially contained an odd number of ones, or 00 if it was even.

126 10 = 1111110 2 may result from the operation of the algorithm from the number 11111 2 .

11111 2 = 31 10 .

Answer: 31.

OR

Let's solve the problem in reverse, and then write the received commands from right to left.

If the number is not divisible by 5, then obtained through command 1, if divisible, then through command 2.

22 + 2 = 24(team 1)

20 + 2 = 22(team 1)

4 * 5 = 20(team 2)

2 + 2 = 4(command 1)

Answer: 1211.

Answer: 31|1211

7. Assignment. A fragment of a spreadsheet is given. The formula was copied from cell E4 to cell D3. When copying, the cell addresses in the formula automatically changed. What is the numerical value of the formula in cell D3?

=$B2 * C$3

Note: The $ sign denotes absolute addressing.

OR

A fragment of a spreadsheet is given.

=(A1-3)/(B1-1)

=(A1-3)/(C1-5)

C1/(A1 – 3)

What integer must be written in cell A1 so that the diagram constructed from the values ​​of cells in the range A2:C2 matches the picture? It is known that all cell values ​​from the considered range are non-negative.

Explanation.

The formula, when copied to cell D3, changed to =$B1 * B$3.

B1 * B3 = 4 * 2 = 8.

Answer: 8.

OR

Let's substitute the values ​​of B1 and C1 into the formulas A2:C2:

A2 = (A1-3)/5

B2 = (A1-3)/5

C2 = 10/(A1-3)

Since A2 = B2, then C2 = 2 * A2 = 2 * B2

Let's substitute:

10/(A1-3) = 2*(A1-3)/5

A1 - 3 = 5

A1 = 8.

Answer: 8.

8. Task Write down the number that will be printed as a result of the following program. For your convenience, the program is presented in five programming languages.

BASIC

Python

DIM S, N AS INTEGER

S=0

N=0

WHILE S

S = S + 8

N=N+2

WEND

PRINT N

s = 0

n=0

while s

s = s + 8

n = n + 2

print(n)

Algorithmic language

Pascal

alg

beginning

integer n, s

n:= 0

s:= 0

nts bye s

s:= s + 8

n:=n+2

kts

output n

con

var s, n: integer;

begin

s:= 0;

n:= 0;

while s

begin

s:= s + 8;

n:=n+2

end;

writeln(n)

end.

Si

#include

int main()

( int s = 0, n = 0;

while (s

printf("%d\n", n);

return 0;

Explanation.

The while loop runs until condition s is true

Answer: 28.

9. Assignment. What is the minimum amount of memory (in KB) that must be reserved to be able to store any 64x64 pixel bitmap image, assuming that the image can contain 256 different colors? In your answer, write down only an integer; there is no need to write a unit of measurement.

OR

The musical fragment was recorded in mono format, digitized and saved as a file without using data compression. The size of the resulting file is 24 MB. Then the same piece of music was recorded again in stereo format (two-channel recording) and digitized with a resolution 4 times higher and a sampling rate 1.5 times lower than the first time. No data compression was performed. Specify the file size in MB of the resulting rewrite. In your answer, write down only an integer; there is no need to write a unit of measurement.

Explanation.

One pixel is encoded by 8 bits of memory.

Total 64 * 64 = 2 12 pixels.

Memory occupied by image 2 12 * 8 = 2 15 bits = 2 12 bytes = 4 KB.

Answer: 4.

OR

When recording the same file in stereo format, its volume increases by 2 times. 24 * 2 = 48

When its resolution increases by 4 times, its volume also increases by 4 times. 48 * 4 = 192

When the sampling frequency is reduced by 1.5 times, its volume decreases by 1.5 times. 192 / 1.5 = 128.

Answer: 128.

Answer: 4|128

10. Task Igor compiles a table of code words for transmitting messages; each message has its own code word. As code words, Igor uses 5-letter words, which contain only the letters P, I, R, and the letter P appears exactly 1 time. Each of the other valid letters can appear in the codeword any number of times or not at all. How many different code words can Igor use?

Explanation.

Igor can make 2 4 words putting the letter P in first place. Similarly, you can put it in second, third, fourth and fifth place. We get 5 * 2 4 = 80 words.

Answer: 80.

11. Task Below, two recursive functions (procedures) are written in five programming languages: F and G.

BASIC

Python

DECLARE SUB F(n)

DECLARE SUB G(n)

SUB F(n)

IF n > 0 THEN G(n - 1)

END SUB

SUB G(n)

PRINT "*"

IF n > 1 THEN F(n - 3)

END SUB

def F(n):

If n > 0:

G(n - 1)

def G(n):

Print("*")

If n > 1:

F(n - 3)

Algorithmic language

Pascal

alg F(integer n)

beginning

If n > 0 then

G(n - 1)

All

con

alg G(integer n)

beginning

Conclusion "*"

If n > 1 then

F(n - 3)

All

con

procedure F(n: integer); forward;

procedure G(n: integer); forward;

procedure F(n: integer);

begin

If n > 0 then

G(n - 1);

end;

procedure G(n: integer);

begin

Writeln("*");

If n > 1 then

F(n - 3);

end;

Si

void F(int n);

void G(int n);

void F(int n)(

If(n>0)

G(n - 1);

void G(int n)(

Printf("*");

If(n>1)

F(n - 3);

How many asterisks will be printed on the screen when calling F(11)?

Explanation.

Let's simulate the operation of the program:

F(11)

G(10): *

F(7)

G(6): *

F(3)

G(2): *

F(-1)

Answer: 3.

12. Assignment In the terminology of TCP/IP networks, a network mask is a binary number that determines which part of the IP address of a network host refers to the network address, and which part refers to the address of the host itself on this network. Typically, the mask is written according to the same rules as the IP address - in the form of four bytes, and each byte is written in the form decimal number. In this case, the mask first contains ones (in the highest digits), and then from a certain digit there are zeros. The network address is obtained by applying a bitwise conjunction to the given host IP address and mask.

For example, if the host IP address is 231.32.255.131 and the mask is 255.255.240.0, then the network address is 231.32.240.0.

For a node with an IP address of 111.81.208.27, the network address is 111.81.192.0. What is the smallest possible value of the third byte from the left of the mask? Write your answer as a decimal number.

Explanation.

Let's write the third byte of the IP address and network address in the binary number system:

208 10 = 11010000 2

192 10 = 11000000 2

We see that the first two bits of the mask on the left are ones, which means that in order for the value to be the smallest, the remaining bits must be zeros. We get that the third mask byte from the left is 11000000 2 = 192 10

Answer: 192.

13. Task When registering in computer system each user is given a password consisting of 15 characters and containing only characters from the 12-character set: A, B, C, D, E, F, G, H, K, L, M, N. In the database for storing information about Each user is allocated the same and minimum possible integer number of bytes. In this case, character-by-character encoding of passwords is used; all characters are encoded with the same and minimum possible number of bits. In addition to the password itself, additional information is stored in the system for each user, for which an integer number of bytes are allocated; this number is the same for all users. To store information about 20 users, 400 bytes were required. How many bytes are allocated to store additional information about one user? In your answer, write down only an integer - the number of bytes.

Explanation.

According to the condition, 12 letters can be used in the number. It is known that using N bits you can encode 2N various options. Since 2 3 4 , then 4 bits are needed to record each of the 12 characters.

To store all 15 characters of a password, you need 4 · 15 = 60 bits, and since an integer number of bytes is used for recording, we take the nearest no less than a multiple of eight, this number is 64 = 8 · 8 bits (8 bytes).

Let the amount of memory allocated for additional storage be equal to x, then:

20 * (8+ x ) = 400

x = 12

Answer: 12.

14. Assignment Executor Editor receives a string of numbers as input and converts it. The editor can execute two commands, in both commands v and w represent strings of numbers.

A) replace (v, w).

This command replaces the first left occurrence of the string v with the string w. For example, running the command

replace (111, 27)

converts the string 05111150 to the string 0527150. If there are no occurrences of v in the string, then running the replace (v, w) command does not change that string.

B) found (v).

This command checks whether the string v occurs in the executor's line Editor. If it is encountered, the command returns the boolean value “true”, otherwise it returns the value “false”. Line

the performer does not change.

Cycle

BYE condition

Command Sequence

END BYE

Executes while the condition is true.

In design

IF condition

TO team1

ELSE command2

END IF

Command1 (if the condition is true) or command2 (if the condition is false) is executed.

What string will result from applying the following

program to a string consisting of 68 consecutive digits 8? In response

write down the resulting string.

START

SO far found (222) OR found (888)

IF found (222)

TO replace (222, 8)

ELSE replace (888, 2)

END IF

END BYE

END

Explanation.

In 68 consecutive numbers 8 there are 22 groups of three eights, which will be replaced by 22 twos and two eights will remain.

68(8) = 22(2) + 2(8)

22(2) + 2(8) = 1(2) + 9(8)

1(2) + 9(8) = 4(2)

4(2) = 1(2) + 1(8) = 28

Answer: 28.

15. Assignment The figure shows a diagram of roads connecting cities A, B, C, D, D, E, F, Z, I, K, L, M.

On each road you can only move in one direction, indicated by the arrow.

How many different routes are there from city A to city M?

Explanation.

Let's start counting the number of paths from the end of the route - from the city M. Let N X - the number of different paths from city A to city X, N - total number ways. You can come to city M from L or K, so N = N M = N L + N K. (*)

Likewise:

N K = N I;

N L = N I;

N I = N E + N F + N W

N K = N E = 1.

Let's add more vertices:

N B = N A = 1;

N B = N B + N A + N G = 1 + 1 + 1 = 3;

N E = N G = 1;

N Г = N A = 1.

Substitute into formula (*): N = N M = 4 + 4 + 4 + 1 = 13.

Answer: 13.

Answer: 56

16. Assignment Arithmetic expression value: 9 8 + 3 5 – 9 – written down in the number system with base 3. How many digits “2” are contained in this notation?

Explanation.

Let's transform the expression:

(3 2 ) 8 + 3 5 - 3 2

3 16 + 3 5 - 3 2

3 16 + 3 5 = 100...00100000

100...00100000 - 3 2 = 100...00022200

The resulting number contains three twos.

Answer: 3

17. Assignment In the search engine query language, the symbol "|" is used to denote the logical operation "OR", and the symbol "&" is used to denote the logical operation "AND". The table shows the queries and the number of pages found for a certain segment of the Internet.

How many pages (in thousands) will be found for the query?Homer & Odyssey & Iliad?It is believed that all queries were executed almost simultaneously, so that the set of pages containing all the searched words did not change over time

fulfilling requests.

Explanation.

The number of requests in this area will be denoted by Ni. Our goal is N5.

Then from the table we find that:

N5 + N6 = 355,

N4 + N5 = 200,

N4 + N5 + N6 = 470.

From the first and second equation: N4 + 2N5 + N6 = 555.

From the last equation: N5 = 85.

Answer: 85

18. Task Let us denote by m&n bitwise conjunction of non-negative integers m and n . So, for example, 14&5 = 1110 2 &0101 2 = 0100 2 = 4.

For what is the smallest non-negative integer And the formula

x&25 ≠ 0 → (x&17 = 0 → x&A ≠ 0)

is identically true (i.e. takes the value 1 for any non-negative integer value of the variable X )?

Explanation.

Let us introduce the following notation:

(x ∈ A) ≡ A; (x ∈ P) ≡ P; (x ∈ Q) ≡ Q.

Transforming, we get:

¬P ∨ ¬(Q ∧ ¬A) ∨ ¬P = ¬P ∨ ¬Q ∨ A.

Logical OR is true if at least one statement is true. Condition ¬P∨ ¬Q = 1 is satisfied by the rays (−∞, 40) and (60, ∞). Since the expression ¬P∨ ¬Q ∨ A must be identically true, the expression A must be true on the interval . Its length is 20.

Answer: 20.

Answer: 8

19. Task The program uses a one-dimensional integer array A with indices from 0 to 9. The values ​​of the elements are 4, 7, 3, 8, 5, 0, 1, 2, 9, 6, respectively, i.e. A = 4, A = 7, etc.

Determine the value of a variable c after executing the next fragment of this program(written below in five programming languages).

BASIC

Python

C=0

FOR i = 1 TO 9

IF A(i)

C = c + 1

T = A(i)

A(i) = A(0)

A(0) = t

ENDIF

NEXT i

C=0

For i in range(1,10):

If A[i]

C = c + 1

t = A[i]

A[i] = A

A = t

Algorithmic language

Pascal

c:= 0

nc for i from 1 to 9

if A[i]

c:= c + 1

t:= A[i]

A[i] := A

A := t

All

kts

c:= 0;

for i:= 1 to 9 do

if A[i]

begin

c:= c + 1;

t:= A[i];

A[i] := A;

A := t;

end;

Si

c = 0;

for (i = 1;i

if (A[i]

{

c++;

t = A[i];

A[i] = A;

A = t;

}

Explanation.

If A[i] array element is less than A, then the program swaps them and increases the value of the variablecby 1. The program will be executed twice, the first time swapping A and A, since 3 Withwill become equal to 2.

Answer: 2.

20. AssignmentThe algorithm is written below in five programming languages. Having received a number as inputx, this algorithm prints the numberM. It is known thatx> 100. Specify the smallest such (i.e. greater than 100) numberx, when entered, the algorithm prints 26.

BASIC

Python

DIM X, L, M AS INTEGER

INPUT X

L=X

M=65

IF L MOD 2 = 0 THEN

M=52

ENDIF

WHILE L M

IF L>M THEN

L = L – M

ELSE

M = M – L

ENDIF

WEND

PRINT M

x = int(input())

L = x

M=65

if L % 2 == 0:

M=52

while L != M:

if L > M:

L = L - M

else:

M = M - L

print(M)

Algorithmic language

Pascal

alg

beginning

int x, L, M

input x

L:=x

M:= 65

if mod(L,2)=0

That

M:= 52

All

nts bye L M

if L > M

That

L:= L – M

otherwise

M:= M – L

All

kts

pin M

con

var x, L, M: integer;

begin

readln(x);

L:=x;

M:= 65;

if L mod 2 = 0 then

M:= 52;

while L M do

if L > M then

L:= L - M

else

M:= M – L;

writeln(M);

end.

Si

#include

void main()

{

int x, L, M;

scanf("%d", &x);

L = x;

M = 65;

if (L % 2 == 0)

M = 52;

while (L != M)(

if(L > M)

L = L - M;

else

M = M - L;

}

printf("%d", M);

}

Explanation.

In the body of the loop, the numbers M and L decrease until they become equal. In order for 26 to be printed in the end, both numbers must equal 26 at some point. Let's go from the end to the beginning: in the previous step, one number was 26, and the other was 26 + 26 = 52. One step earlier, 52 + 26 = 78 and 52. Before that, 78 + 52 = 130 and 52. That is, the smallest possible number is 130. And since the found number is even, then M will be assigned the value 52, which will lead to the desired result.

Answer: 130.

21. TaskWrite in reply smallest value input variablek, at which the program produces the same answer as with the input valuek= 10. For your convenience, the program is provided in five programming languages.

BASIC

Python

DIM K, I AS LONG

INPUT K

I = 1

WHILE F(I)

I = I + 1

WEND

PRINT I

FUNCTION F(N)

F=N*N*N

END FUNCTION

FUNCTION G(N)

G = 2*N + 3

END FUNCTION

def f(n):

return n*n*n

def g(n):

return 2*n+3

k = int(input())

i = 1

while f(i)

i+=1

print(i)

Algorithmic language

Pascal

alg

beginning

int i, k

input k

i:= 1

nts for now f(i)

i:= i + 1

kts

output i

con

alg integer f(integer n)

beginning

value:= n * n * n

con

alg integer g(integer n)

beginning

value:= 2*n + 3

con

var

k, i: longint;

function f(n: longint): longint;

begin

f:= n * n * n;

end;

function g(n: longint): longint;

begin

g:= 2*n + 3;

end;

begin

readln(k);

i:= 1;

while f(i)

i:= i+1;

writeln(i)

end.

Si

#include

long f(long n) (

return n * n * n;

}

long g(long n) (

return 2*n + 3;

}

int main()

{

long k, i;

scanf("%ld", &k);

i = 1;

while(f(i)

i++;

printf("%ld", i);

return 0;

}

Explanation.

This program compares And and adds toiunit until . And outputs the first value of the variableiat which

If k = 10, the program will print the number 3.

Let's write down the inequality: from here we get that the smallest valuek = 3.

Answer: 3.

22. AssignmentPerformer May15 converts the number on the screen. The performer has two teams, which are assigned numbers:

1. Add 1

2. Multiply by 2

The first command increases the number on the screen by 1, the second multiplies it by 2. The program for the May15 performer is a sequence of commands. How many programs are there for which, given the initial number 2, the result is the number 29 and at the same time the computation trajectory contains the number 14 and does not contain the number 25?

The computation path of a program is a sequence of results

execution of all program commands. For example, for program 121 with the initial number 7, the trajectory will consist of the numbers 8, 16, 17.

Explanation.

For addition, the commutative law is valid, which means that the order of commands in the program does not matter for the result.

All teams increase the initial number, so the number of teams cannot exceed (30 − 21) = 9. In this case minimal amount teams - 3.

Thus, the number of commands can be 3, 4, 5, 6, 7, 8 or 9. Therefore, the order of the commands does not matter; for each number of commands there is one set of commands, which can be arranged in any order.

Let's consider all possible sets and calculate the number of options for placing commands in them. Set 133 has 3 possible layout options. Set 1223 - 12 possible arrangements: this is the number of permutations with repetitions (1+2+1)!/(1! · 2! · 1!)). Set 12222 - 5 options. Set 111222 - 20 possible options. Set 11123 - 20 options. Set 111113 - 6 options, set 1111122 - 21 options, set 11111112 - 8 options, set 111111111 - one option.

In total we have 3 + 12 + 5 + 20 + 20 + 6 + 21 + 8 + 1 = 96 programs.

Answer: 96.

Answer: 96.

Answer: 13

23. AssignmentHow many different sets of Boolean variable values ​​are there?x1 , x2 , ... x9 , y1 , y2 , ... y9 , which satisfy all the conditions listed below?

(¬ (x1 y1 )) ≡ (x2 y2 )

(¬ (x2 y2 )) ≡ (x3 y3 )

(¬ (x8 y8 )) ≡ (x9 y9 )

The answer does not need to list all the different sets of variable values.x1 , x2 , ... x9 , y1 , y2 , ... y9 , at which it is fulfilled this system equals As an answer, you need to indicate the number of such sets.

Explanation.

From the last equation we find that there are three possible options for the values ​​of x8 and y8: 01, 00, 11. Let’s build a tree of options for the first and second pairs of values.

Thus, we have 16 sets of variables.

Tree of options for value pair 11:

We get 45 options. Thus, the system will have 45 + 16 = 61 different solution sets.

Answer: 61.

Answer: 1024

24. AssignmentA positive integer not exceeding 10 is received for processing9 . You need to write a program that displays the sum of the digits of this number less than 7. If the number contains no digits less than 7, you need to display 0. The programmer wrote the program incorrectly. Below this program is presented in five programming languages ​​for your convenience.

BASIC

Python

DIM N, DIGIT, SUM AS LONG

INPUT N

SUM = 0

WHILE N > 0

DIGIT = N MOD 10

IF DIGIT

SUM = SUM + 1

END IF

N=N\10

WEND

PRINT DIGIT

N = int(input())

sum = 0

while N > 0:

digit = N% 10

if digit

sum = sum + 1

N = N // 10

print(digit)

Algorithmic language

Pascal

alg

beginning

integer N, digit, sum

input N

sum:= 0

nts while N > 0

digit:= mod(N,10)

if digit

sum:= sum + 1

All

N:= div(N,10)

kts

output digit

con

var N, digit, sum: longint;

begin

readln(N);

sum:= 0;

while N > 0 do

begin

digit:= N mod 10;

if digit

sum:= sum + 1;

N:= N div 10;

end;

writeln(digit)

end.

Si

#include

int main()

{

int N, digit, sum;

scanf("%d", &N);

sum = 0;

while (N > 0)

{

digit = N% 10;

if (digit

sum = sum + 1;

N = N / 10;

}

printf("%d",digit);

return0;

}

Do the following in sequence.

1. Write what this program will output when you enter the number 456.

2. Give an example of a three-digit number, when entered, the program produces the correct answer.

3. Find all the errors in this program (there may be one or more). It is known that each error affects only one line and can be corrected without changing other lines. For each error:

1) write down the line in which the error was made;

2) indicate how to fix the error, i.e. give the correct version of the line.

It is enough to indicate the errors and how to correct them for one programming language. Please note that you need to find errors in an existing program, and not write your own, possibly using a different solution algorithm. The error correction should only affect the line where the error is located.

Explanation.

The solution uses a Pascal program notation. You can use the program in any of the four other languages.

1. The program will print the number 4.

2. An example of a number, when entered, the program gives the correct answer: 835.

Note for the reviewer. The program does not work correctly because the variable displayed is incorrect and the amount is incremented incorrectly. Accordingly, the program will work correctly if the highest digit in the number (the leftmost one) is equal to the sum of the digits less than 7.

3. There are two errors in the program.

First mistake. Incorrect increase in amount.

Error line:

sum:= sum + 1;

Correct fix:

sum:= sum + digit;

Second mistake. Incorrect response displayed on screen.

Error line:

writeln(digit)

Correct fix:

writeln(sum)

25. AssignmentGiven an integer array of 20 elements. Array elements can take integer values ​​from –10,000 to 10,000 inclusive. Describe on natural language or in one of the programming languages ​​an algorithm that allows you to find and display the number of pairs of array elements in which at least one number is divisible by 3. In this problem, a pair means two consecutive array elements. For example, for an array of five elements: 6; 2; 9; –3; 6 – answer: 4.

The input data is declared as shown below in examples for some programming and natural language languages. It is prohibited to use variables not described below, but it is permitted not to use some of the described variables.

BASIC

Python

CONST N AS INTEGER = 20

DIM A (1 TO N) AS INTEGER

DIM I AS INTEGER,

J AS INTEGER,

K AS INTEGER

FOR I = 1 TO N

INPUT A(I)

NEXT I

...

END

# also allowed

# use two

# integer variables j and k

a =

n = 20

for i in range(0, n):

a.append(int(input()))

...

Algorithmic language

Pascal

alg

beginning

int N = 20

celtab a

int i, j, k

nc for i from 1 to N

input a[i]

kts

...

con

const

N = 20;

var

a: array of integer;

i, j, k: integer;

begin

for i:= 1 to N do

readln(a[i]);

...

end.

Si

Natural language

#include

#define N 20

int main() (

int a[N];

int i, j, k;

for (i = 0; i

scanf("%d", &a[i]);

...

return 0;

}

We declare an array A of 20 elements.

We declare integer variables I, J, K.

In a loop from 1 to 20, we enter elements of array A from 1 to 20.

As an answer, you need to provide a fragment of the program (or a description of the algorithm in natural language), which should be located in the place of the ellipsis. You can also write the solution in another programming language (indicate the name and version of the programming language used, for example Free Pascal 2.6) or in the form of a flowchart. In this case, you must use the same input data and variables that were proposed in the condition (for example, in a sample written in natural language).

k:= k+1

All

kts

output k

Pascal

k:= 0;

for i:= 1 to N-1 do

if (a[i] mod 3=0) or (a mod 3=0) then

inc(k);

writeln(k);

Si

k = 0;

for (i = 0; i

if (a[i]%3 == 0 || a%3 == 0)

k++;

printf("%d", k);

Natural language

We write the initial value equal to 0 into the variable K. In a loop from the first element to the penultimate one, we find the remainder of dividing the current and next element of the array by 3. If the first or second of the resulting remainders is equal to 0, we increase the variable K by one. After the loop completes, print the value of the variable K

26. AssignmentTwo players, Petya and Vanya, play the following game. In front of the players are two piles of stones. The players take turns, Petya makes the first move. During one turn, the player can add one stone to one of the piles (of his choice) or double the number of stones in the pile. For example, let there be 10 stones in one pile and 7 stones in another; We will denote such a position in the game by (10, 7). Then in one move you can get any of four positions: (11, 7), (20, 7), (10, 8), (10, 14). In order to make moves, each player has an unlimited number of stones.

The game ends when the total number of stones in the piles becomes at least 73. The winner is the player who made the last move, i.e. the first to receive such a position that the piles will contain 73 stones or more.

We will say that a player has a winning strategy if he can win with any moves of the opponent. To describe a player's strategy means to describe what move he should make in any situation that he may encounter with different plays from the opponent. For example, with initial positions (6, 34), (7, 33), (9, 32), Petya has a winning strategy. To win, he only needs to double the number of stones in the second pile.

Exercise 1.For each of the starting positions (6, 33), (8, 32), indicate which player has the winning strategy. In each case, describe the winning strategy; explain why this strategy leads to a win, and indicate the largest number of moves a winner might need to win with this strategy.

Task 2.For each of the starting positions (6, 32), (7, 32), (8, 31), indicate which player has the winning strategy. In each case, describe the winning strategy; explain why this strategy leads to a win, and indicate the largest number of moves a winner might need to win with this strategy.

Task 3.For the starting position (7, 31), indicate which player has the winning strategy. Describe a winning strategy; explain why this strategy leads to a win, and indicate the largest number of moves a winner might need to win with this strategy. Construct a tree of all games possible with the winning strategy you specified. Imagine the tree as a picture or table.

(7,31)

Total 38

(7,31+1)=(7,32)

Total 39

(7+1,32)=(8,32)

Total 40

(8+1,32)=(9,32)

Total 41

(9,32*2)=(9,64)

Total 73

(8,32+1)=(8,33)

Total 41

(8,33*2)=(8,66)

Total 74

(8*2,32)=(16,32)

Total 48

(16,32*2)=(16,64)

Total80

(8,32*2)=(8,64)

Total 72

(8,64*2)=(8,128)

Total 136

(7+1,31)=(8,31)

Total 39

(8,31+1)=(8,32)

Total 40

(8+1,32)=(9,32)

Total 41

(9,32*2)=(9,64)

Total 73

(8,32+1)=(8,33)

Total41

(8,33*2)=(8,66)

Total 74

(8*2,32)=(16,32)

Total 48

(16,32*2)=(16,64)

Total 80

(8,32*2)=(8,64)

Total 72

(8,64*2)=(8,128)

Total 136

(7*2,31)=(14,31)

Total 45

(14,31*2)=(14,62)

Total 76

(7,31*2)=(7,62)

Total 69

(7,62*2)=(7,124)

Total 131

Exercise 1.In the initial positions (6, 33), (8, 32), Vanya has a winning strategy. With the initial position (6, 33), after Petya’s first move, one of the following four positions can result: (7, 33), (12, 33), (6, 34), (6, 66). Each of these positions contains less than 73 stones. Moreover, from any of these positions Vanya can get a position containing at least 73 stones, doubling the number of stones in the second pile. For position (8, 32), after Petya’s first move, one of the following four positions can result: (9, 32), (16, 32), (8, 33), (8, 64). Each of these positions contains less than 73 stones. Moreover, from any of these positions Vanya can get a position containing at least 73 stones, doubling the number of stones in the second pile. Thus, Vanya, at any move of Petya

wins with his first move.

Task 2.In the initial positions (6, 32), (7, 32) and (8, 31), Petya has a winning strategy. With the initial position (6, 32), he must first move to obtain the position (6, 33), from the initial positions (7, 32) and (8, 31). After the first move, Petya must get position (8, 32). Positions (6, 33) and (8, 32) were considered when analyzing task 1. In these positions, the winning strategy is for the player who will go second (now this is Petya). This strategy was described in the analysis of task 1. Thus, Petya wins with his second move in any game of Vanya.

Task 3.In the initial position (7, 31), Vanya has a winning strategy. After Petit's first move, one of four positions can arise: (8, 31), (7, 32), (14, 31) and (7, 62). In positions (14, 31) and (7, 62) Vanya can win in one move by doubling the number of stones in the second pile. Positions (8, 31) and (7, 32) were considered when analyzing task 2. In these positions, the player who must make a move (now Vanya) has a winning strategy. This strategy is described in the analysis of task 2. Thus, depending on the game, Petya Vanya wins on the first or second move.

27. AssignmentA long-term experiment to study the Earth's gravitational field is being conducted in a physics laboratory. Every minute, a positive integer is transmitted via the communication channel to the laboratory - the current reading of the Sigma 2015 device. The number of transmitted numbers in the series is known and does not exceed 10,000. All numbers do not exceed 1000. The time during which the transmission occurs can be neglected.

It is necessary to calculate the “beta value” of a series of instrument readings - the minimum even product of two readings, between the moments of transmission of which at least 6 minutes have passed. If it is not possible to obtain such a product, the answer is considered equal to –1.

You are offered two tasks related to this task: task A and task B. You can solve both tasks or one of them according to your choice. The final grade is given as the maximum of the grades for tasks A and B. If the solution to one of the tasks is not presented, then the grade for this task is considered to be 0 points. Task B is a more complicated version of task A; it contains additional requirements for the program.

A. Write a program in any programming language to solve the problem, in which the input data will be stored in an array, after which all possible pairs of elements will be checked. Before the program, indicate the version of the programming language.

MAKE SURE to indicate that the program is a solution to TASK A.

The maximum score for completing task A is 2 points.

B. Write a program to solve the given problem that will be efficient in both time and memory (or at least one of these characteristics).

A program is considered time efficient if the operating time is

program is proportional to the number of readings received from the device N, i.e. When N increases by a factor of k, the running time of the program should increase by no more than k times.

A program is considered memory efficient if the size of memory used in the program to store data does not depend on the number N and does not exceed 1 kilobyte.

Before the program, indicate the version of the programming language and briefly describe the algorithm used.

MAKE SURE to indicate that the program is a solution to TASK B.

The maximum score for a correct program that is effective in time and memory is 4 points.

The maximum score for a correct program that is time efficient but memory ineffective is 3 points. REMINDER! Do not forget to indicate which task each of the programs you submit relates to.

The input data is presented as follows. The first line specifies the number N – the total number of instrument readings. It is guaranteed that N > 6. Each of the next N lines contains one positive integer – the next reading of the device.

Example input data:

11

12

45

5

3

17

23

21

20

19

18

17

The program must output one number - the product described in the condition, or -1 if it is not possible to obtain such a product.

Example output for the example input above:

54

Explanation.

Task B (the solution for task A is given below, see program 4). For the product to be even, at least one factor must be even, therefore, when searching for suitable products, even readings of the device can be considered in pairs with any others, and odd ones - only with even ones.

For each reading with number k, starting with k = 7, we consider all pairs that are admissible under the conditions of the problem, in which this reading was obtained second. The minimum product of all these pairs will be obtained if the first in the pair is taken the minimum suitable reading among all received from the beginning of reception until the reading with number k - 6. If the next reading is even, the minimum among the previous ones can be any, if odd - only even.

To obtain a time-effective solution, as you enter data, you need to remember the absolute minimum and minimum even readings at each point in time, multiply each newly obtained reading by the corresponding minimum that existed 6 elements earlier, and select the minimum of all such products.

Since each current minimum reading is used after 6 more elements have been entered and is no longer needed after that, it is sufficient to store only the last 6 minimums. To do this, you can use an array of 6 elements and fill it cyclically as data is entered. The size of this array does not depend on the total number of entered readings, so this solution will be efficient not only in time, but also in memory. To store the absolute and even minimums, you need to use two such arrays. Below is an example of such a program written in an algorithmic language.

Example 1. An example of a correct program in an algorithmic language. The program is efficient in both time and memory.

alg

beginning

integer s = 6 | required distance between readings

integer amax = 1001 | greater than the maximum possible reading

integer N

input N

int a | next instrument reading

celtab mini | current minimums of the last s elements

celtab minichet | even minima of the last s elements

whole i

| enter the first s readings, fix the minimums

whole ma; ma:= amax | minimum reading

rushes intact; rushes:= amax | minimum even reading

nc for i from 1 to s

input a

ma:= imin(ma, a)

mini := ma

minichet := rush

kts

int mp = amax*amax | minimum value of the product

whole n

nc for i from s+1 to N

input a

if mod(a,2)=0

then n:= a * mini

otherwise if it rushes

then p:= a * minieven

else p:= amax*amax;

All

All

mp:= imin(mp, n)

ma:= imin(ma, a)

if mod(a,2) = 0 then rushes:= imin(rushes,a) all

mini := ma

minichet := rush

kts

if mp = amax*amax then mp:=-1 all

MP output

con

Other implementations are possible. For example, instead of filling an array cyclically, you can shift its elements each time. In the example below, it is not the minimums that are stored and shifted, but the original values. This requires slightly less memory (one array is enough instead of two), but the solution with shifts is less time efficient than with cyclic filling. However, the operating time remains proportional to N, so the maximum score for this solution is also 4 points.

Program 2. An example of a correct program in Pascal.

The program uses shifts, but is time and memory efficient

var

N: integer;

a: array of integer; (storing s instrument readings)

a_:integer; (entering the next reading)

p:integer;

i, j: integer;

begin

readln(N);

(Input of first s numbers)

for i:=1 to s do readln(a[i]);

(Enter the remaining values, search for the minimum product)

ma:= amax; me:= amax;

mp:=amax*amax;

for i:= s + 1 to N do begin

readln(a_);

if a

if (a mod 2 = 0) and (a

if a_ mod 2 = 0 then p:= a_ * ma

else if me

else p:= amax* amax;

if(p

(shift the elements of the auxiliary array to the left)

for j:= 1 to s - 1 do

a[j] := a;

a[s] := a_

end;

if mp = amax*amax then mp:=-1;

writeln(mp)

end.

If, instead of a small fixed-size array (either circular or with shifts), all the original data (or all the current minimums) is stored, the program remains time efficient, but becomes memory inefficient, since the required memory grows proportionally to N. Below is an example of such a program in the language Pascal. Similar (and essentially similar) programs are rated no higher than 3 points.

Program 3. An example of a correct program in Pascal. The program is time efficient, but memory inefficient

const s = 6; (required distance between readings)

amax = 1001; (more than the maximum possible reading)

var

N, p, i: integer;

ma:integer; (minimum number without last s)

me:integer; (minimum even number without the last s)

mp:integer; (minimum value of the product)

begin

readln(N);

(Entering all instrument readings)

for i:=1 to N do readln(a[i]);

ma:= amax;

me:= amax;

mp:= amax*amax;

for i:= s + 1 to N do

begin

if a

if (a mod 2 = 0) and (a

me:= a;

if a[i] mod 2 = 0 then p:= a[i] * ma

else if me

else p:= amax * amax;

if(p

end;

if mp = amax*amax then mp:= -1;

writeln(mp)

end.

An exhaustive search solution is also possible, in which the products of all possible pairs are found and the minimum one is selected from them. Below (see program 4) is an example of such a solution. This (and similar) solutions are neither time nor memory efficient. It is a solution to task A, but not a solution to task B. The score for such a solution is 2 points.

Program 4. An example of a correct program in Pascal. The program is inefficient neither in time nor in memory

const s = 6; (required distance between readings)

var

N: integer;

a: array of integer; (all instrument readings)

mp:integer; (minimum value of the product)

i, j: integer;

begin

readln(N);

(Input of device values)

for i:=1 to N do

readln(a[i]);

mp:= 1000 * 1000 + 1;

for i:= 1 to N-s do begin

for j:= i+s to N do begin

if (a[i]*a[j] mod 2 = 0) and (a[i]*a[j]

then mp:= a[i]*a[j]

end;

end;

if mp = 1000 * 1000 + 1 then mp:= -1;

writeln(mp)

For school graduates. It should be taken by those who plan to enter universities for the most promising specialties, such as information security, automation and control, nanotechnology, systems analysis and control, missile systems and astronautics, nuclear physics and technology and many others.

Check out general information about the exam and start preparing. There are practically no changes compared to last year in the new version of the KIM Unified State Exam 2019. The only thing is that fragments of programs written in the C language disappeared from the tasks: they were replaced with fragments written in the C++ language. And from task No. 25, they removed the opportunity to write an algorithm in natural language as an answer.

Unified State Examination assessment

Last year, to pass the Unified State Exam in computer science with at least a C, it was enough to score 42 primary points. They were given, for example, for correctly completing the first 9 tasks of the test.

It is not yet known exactly what will happen in 2019: we need to wait for an official order from Rosobrnadzor on the compliance of primary and test scores. Most likely it will appear in December. Considering that the maximum primary score remained the same throughout the test, most likely it will not change and minimum score. Let's focus on these tables for now:

Structure of the Unified State Exam test

Computer science is the longest exam (the Unified State Examination in mathematics and literature is the same length), lasting 4 hours.

In 2019, the test consists of two parts, including 27 tasks.

  • Part 1: 23 tasks (1–23) with a short answer, which is a number, a sequence of letters or numbers.
  • Part 2: 4 tasks (24–27) with detailed answers, complete solutions to the tasks are written down on answer sheet 2.

All tasks are connected in one way or another with a computer, but during the exam you are not allowed to use it to write a program in group C problems. In addition, the problems do not require complex mathematical calculations and the use of a calculator is also not allowed.

Preparation for the Unified State Exam

  • Take the Unified State Exam tests online for free without registration or SMS. The tests presented are identical in complexity and structure to the actual exams conducted in the corresponding years.
  • Download demo versions of the Unified State Examination in computer science, which will allow you to better prepare for the exam and pass it easier. All proposed tests have been developed and approved for preparation for the Unified State Exam. Federal Institute pedagogical measurements (FIPI). In the same FIPI all official Unified State Exam options.
    The tasks that you will see most likely will not appear on the exam, but there will be tasks similar to the demo ones, on the same topic or simply with different numbers.

General Unified State Examination figures

Year Minimum Unified State Examination score Average score Number of participants Failed, % Qty
100 points
Duration-
Exam length, min.
2009 36
2010 41 62,74 62 652 7,2 90 240
2011 40 59,74 51 180 9,8 31 240
2012 40 60,3 61 453 11,1 315 240
2013 40 63,1 58 851 8,6 563 240
2014 40 57,1 235
2015 40 53,6 235
2016 40 235
2017 40 235
2018

SPECIFICATION
control measuring materials
single state exam 2016
in computer science and ICT

1. Purpose of KIM Unified State Exam

The Unified State Exam (hereinafter referred to as the Unified State Exam) is a form of objective assessment of the quality of training of persons who have mastered educational programs average general education, using tasks of a standardized form (control measuring materials).

The Unified State Examination is conducted in accordance with the Federal Law of December 29, 2012 No. 273-FZ “On Education in the Russian Federation.”

Tests measuring materials make it possible to establish the level of mastery by graduates of the Federal component of the state standard of secondary (complete) general education in computer science and ICT, basic and specialized levels.

The results of the unified state exam in computer science and ICT are recognized educational organizations average vocational education and educational organizations of higher professional education as results entrance examinations in computer science and ICT.

2. Documents defining the content of the Unified State Exam KIM

3. Approaches to selecting content and developing the structure of the Unified State Exam KIM

The content of the assignments is developed on the main topics of the computer science and ICT course, combined into the following thematic blocks: “Information and its coding”, “Modeling and computer experiment”, “Number systems”, “Logic and algorithms”, “Elements of the theory of algorithms”, “Programming” ", "Architecture of computers and computer networks", "Processing of numerical information", "Technologies for searching and storing information."
The content of the examination paper covers the main content of the computer science and ICT course, its most important topics, the most significant material in them, which is clearly interpreted in most versions of the computer science and ICT course taught at school.

The work contains both tasks of a basic level of complexity, testing knowledge and skills provided for by the basic level standard, and
and tasks of increased and high levels of complexity, testing knowledge and skills provided for by the profile level standard. The number of tasks in the CMM version should, on the one hand, provide a comprehensive test of the knowledge and skills of graduates acquired over the entire period of study in the subject, and, on the other hand, meet the criteria of complexity, stability of results, and reliability of measurement. For this purpose, CIM uses two types of tasks: with a short answer and a detailed answer. The structure of the examination paper ensures an optimal balance of tasks different types and varieties, three levels of difficulty, testing knowledge and skills at three different levels: reproduction, application in a standard situation, application in a new situation. The content of the examination paper reflects a significant part of the content of the subject. All this ensures the validity of the test results and the reliability of the measurement.

4. Structure of KIM Unified State Exam

Each version of the examination paper consists of two parts and includes 27 tasks that differ in form and level of difficulty.

Part 1 contains 23 short answer questions.

IN exam paper The following types of short-answer tasks are offered:

  • tasks for choosing and recording one or more correct answers from the proposed list of answers;
  • tasks to calculate a certain value;
  • tasks to establish the correct sequence, presented as a string of characters according to a specific algorithm.

The answer to the tasks of Part 1 is given by the corresponding entry in the form of a natural number or a sequence of characters (letters and numbers), written without spaces or other separators.

Part 2 contains 4 tasks with detailed answers.

Part 1 contains 23 tasks of basic, advanced and high difficulty levels. This part contains short-answer tasks that require you to independently formulate and write the answer in the form of a number or a sequence of characters. The assignments test the material of all thematic blocks. In Part 1, 12 tasks relate to basic level, 10 tasks for an increased level of complexity, 1 task for a high level of complexity.

Part 2 contains 4 tasks, the first of which is of an increased level of complexity, the remaining 3 tasks are of a high level of complexity. The tasks in this part involve writing a detailed answer in free form.

K.Yu. Polyakov
Unified State Exam in Computer Science:
2016 and beyond...
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

Structural changes in 2015-2016


2
Structural changes in 2015-2016
1) removal of part A
2) reducing the number of tasks
3) association simple tasks (4, 6, 7, 9)
Goal: leave more time to decide
complex tasks.
4) Python language
!
K.Yu. Polyakov, 2015
Variability!
http://kpolyakov.spb.ru

Unified State Exam in Computer Science: 2016 and beyond...
3

How many ones are there in binary notation?
hexadecimal number 12F016.
1
2
12 102
F
11112
0
1+1+4=6
Specify the smallest number whose binary notation is
contains exactly three significant zeros and three ones.
Write your answer in decimal number system
1000112 = 35
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B1: binary number system

Unified State Exam in Computer Science: 2016 and beyond...
4
B1: binary number system

numbers 1025?
1) “on the forehead” - translate...
2) 1025 = 1024 + 1
1024 = 100000000002
1025 = 100000000012
Answer: 2
511?
511 = 512 - 1
= 10000000002 - 1 = 1111111112
Answer: 9
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B1: binary number system

Unified State Exam in Computer Science: 2016 and beyond...
5
B1: binary number system
How many units are there in binary decimal notation?
numbers 999?
1) “on the forehead” - translate...
2) 999 = 1023 – 16 – 8
1023 = 1024 – 1 = 11111111112
minus two units: 8
519?
519 = 512 + 7
512 = 10000000002
7 = 1112
plus three ones: 4
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B1: number systems

Unified State Exam in Computer Science: 2016 and beyond...
6
B1: number systems
Which of the following numbers can be written in
binary number system in the form 1xxx10, where x can
mean both 0 and 1?
1) 74
2) 38
3) 60
4) 47
1) 1000102 = 34 N 1111102 = 62
2) 1xxx10 is divisible by 2
3) 1xxx10 is not divisible by 4
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B2: logic functions

Unified State Exam in Computer Science: 2016 and beyond...
7
B2: logic functions
x1
1
!
x2
0
x3
x4
0
1
x5
x6
x7
x8
1
1
F
0
1
1
All options are simple AND or OR!
1) “on the forehead” - substitute into formulas...
2) if all “OR” is one zero
check the line where F = 0
x2 without inversion, x8 with inversion
3) if all “I”s are one unit
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B2: logic functions

Unified State Exam in Computer Science: 2016 and beyond...
8
B2: logic functions
Given a function table z x x

?z
0
0
0
0
1
1
1
1
?y
0
0
1
1
0
0
1
1
K.Yu. Polyakov, 2015
?x
0
1
0
1
0
1
0
1
F
0
1
0
1
0
0
0
1
y.
z x x y
x (z y)
x 0 F 0
x 1
z 1
F 0
y 0
Answer: zyx
http://kpolyakov.spb.ru

B2: logic functions

Unified State Exam in Computer Science: 2016 and beyond...
9
B2: logic functions
Given a function table x y z x
Determine which columns are x, y and z.
?z
0
0
0
0
1
1
1
1
?x
0
0
1
1
0
0
1
1
K.Yu. Polyakov, 2015
?y
0
1
0
1
0
1
0
1
F
0
0
1
0
1
1
1
1
y z.
x y z x y z
z 0 F x y
z 1 F x y x y
(x x) (y x) y
y x y 1
z 0
x 1 Answer: zxy
F 1
y 0
http://kpolyakov.spb.ru

B3: graph weight matrices

Unified State Exam in Computer Science: 2016 and beyond...
10
B3: graph weight matrices
A
A
B
C
D
E
F
Z
B
4
C
6
3
D
E
F
11
4
5
7
4
Z
30
27
10
8
2
29
1) asymmetric matrix (digraph)
2) two one-way roads
3) “how many roads are there passing through N
points?
4) “... no less than N points?”
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B3: graph weight matrices

Unified State Exam in Computer Science: 2016 and beyond...
11
B3: graph weight matrices
1
1
2
2
3
45
4
5
6
6
45
55
3
15 60
2
10 40
15
20 35
4
55
2
55 60 20 55
35
45
45
E
A
5
2
degrees
peaks
K.Yu. Polyakov, 2015
D
2
40
7
B
7
10
3
4
5
TO
IN
degree 4
degree 5
G
Answer: 20
http://kpolyakov.spb.ru

B4-1: Tabular Databases

Unified State Exam in Computer Science: 2016 and beyond...
12
B4-1: Tabular Databases
1) how many descendants (children, grandchildren, great-grandchildren...) does X have?
2) how many ancestors of X are there in the table?
3) find your maternal grandfather
23
24
25
K.Yu. Polyakov, 2015
34
57
35
42
http://kpolyakov.spb.ru

Unified State Exam in Computer Science: 2016 and beyond...
13

Messages contain the letters P, O, S, T; used
binary code that can be unambiguous
decoding. Code words:
T: 111, O: 0, P: 100.
Specify the shortest code word for the letter C, when
in which the code will allow unambiguous
decoding. If there are several such codes, please indicate
code with the smallest numeric value.
1
0
0x10
0xx
ABOUT
11
101
P
K.Yu. Polyakov, 2015
0
0
110
1
1
1
0
1
T
http://kpolyakov.spb.ru

B5: Encoding and Decoding

Unified State Exam in Computer Science: 2016 and beyond...
14
B5: Encoding and Decoding
Messages contain three vowel letters: A, E, I – and five
consonant letters: B, V, G, D, K. Letters are coded
prefix code. It is known that all code words for
consonants have the same length, and
A –1, E – 01, I – 001.
What is the smallest possible length of codewords for
consonants?
0
5 consonants 3 bits 4 bits 5 bits
4: 1xx
0
1
2:01x
0
1
A
1: 001
1
E
free: 000
000x 000xx
1
2
4
AND
K.Yu. Polyakov, 2015
6 bit
000xxx
8
http://kpolyakov.spb.ru

B6-1: automatic

Unified State Exam in Computer Science: 2016 and beyond...
15
B6-1: automatic
parity restored!
Input: natural number N.
1. A parity bit is added to the end of the binary record
(sum of digits mod 2).
2. Another parity bit is added to the received string.
Enter the smallest number for which the result is
execution of this algorithm will result in the number
more than 125.
!
Step 2 adds 0 2!
Should get even = 126 or 128
Parity must be preserved after div 2!
126 / 2 = 63 = 1111112: – 6 units, parity
Answer:
K.Yu. Polyakov, 2015
31
http://kpolyakov.spb.ru

B10: combinatorics

Unified State Exam in Computer Science: 2016 and beyond...
16
B10: combinatorics
How many 5-letter words are there that only contain
the letters P, I, R, and the letter P appears exactly 1 time.
P****
*P***
**P**
***P*
****P
K.Yu. Polyakov, 2015
24 = 16 words
Answer: 16·5 = 80.
http://kpolyakov.spb.ru

B12: addressing in networks

Unified State Exam in Computer Science: 2016 and beyond...
17
B12: addressing in networks
IP address 224.128.112.142
The network address is 224.128.64.0.
What is the third byte from the left of the mask?
don't forget about
*.*.112.*
senior units!
*.*.64.0
mask: 110000002 = 192
192
112 = 011100002
64 = 010000002
!
K.Yu. Polyakov, 2015
Bitwise conjunction!
http://kpolyakov.spb.ru

B12: addressing in networks

Unified State Exam in Computer Science: 2016 and beyond...
18
B12: addressing in networks
IP address 111.81.208.27
The network address is 111.81.192.0.
What is the minimum value of the third one from the left
mask byte?
*.*.208.*
*.*.192.0
208 =
192 =
mask:
mask:
110100002
110000002
111000002
110000002
192
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B14: Draftsman

Unified State Exam in Computer Science: 2016 and beyond...
19
B14: Draftsman
shift by (–3, –3) 1)
REPEAT N TIMES
2)
move to (a, b) 3)
move to (27, 12) 4)
END REPEAT
shift by (–22, -7)
3 N x 22 0
3 N y 7 0
smallest N > 1
largest N
all possible N
sum of all N
N x 25
Ny 10
N = common divisor(25,10)
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B14: Editor

Unified State Exam in Computer Science: 2016 and beyond...
20
B14: Editor
1) replace(v,w)
2) found(v)
SO far found (222) OR found (888)
IF found (222)
TO replace (222, 8)
ELSE replace (888, 2)
What is the result of processing line 88888...8?
888888888…8
2 2 2
8
K.Yu. Polyakov, 2015
!
In 4 steps
removed
8 eights!
68 - 8 8 = 4
68
8888 28
http://kpolyakov.spb.ru

Unified State Exam in Computer Science: 2016 and beyond...
21


city ​​A to city L without passing through B?
D
B
AND
IN
A
G
K.Yu. Polyakov, 2015
AND
E
L
TO
http://kpolyakov.spb.ru

B15: number of paths in graphs

Unified State Exam in Computer Science: 2016 and beyond...
22
B15: number of paths in graphs
How many different paths are there from
city ​​A to city L, passing through D?
D
B
AND
IN
A
G
K.Yu. Polyakov, 2015
AND
E
L
TO
http://kpolyakov.spb.ru

B16: Number systems

Unified State Exam in Computer Science: 2016 and beyond...
23
B16: Number systems
How many ones are in binary
(ternary, ...) notation for the number X?
10N = 100…0
10N-1 = 99…9
N
N
2N = 100…02
N
3N = 100…03
N
K.Yu. Polyakov, 2015
2N-1 = 11…1
N
3N-1 = 22…2
N
http://kpolyakov.spb.ru

B16: Number systems

Unified State Exam in Computer Science: 2016 and beyond...
24
B16: Number systems
2N – 2M = 2M (2N-M – 1)
= 100…02 11…12
N-M
M
= 11…100…02
N-M
K.Yu. Polyakov, 2015
M
http://kpolyakov.spb.ru

B16: Number systems

Unified State Exam in Computer Science: 2016 and beyond...
25
B16: Number systems

numbers (24400–1)·(42200+2)?
(24400–1)·(42200+2) = (24400–1)·(24400+1+1)
= (24400–1) (24400+1) + 24400–1
= 28800 – 1 + 24400–1
= 28800 + 24400 – 21
1
4399
1 + 4399 = 4400
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B16: Number systems

Unified State Exam in Computer Science: 2016 and beyond...
27
B16: Number systems
How many ones are there in binary notation?
the meaning of the number 8148 – 4123 + 2654 – 17?
8148 = 2444
4123 = 2246
2654
17 = 16 + 1
= 24 + 2 0
2654 + 2444 – 2246 – 24 – 20
444 – 2246 – 24 – 20
2
1
444 – 2
1 + 444 – 2 = 443
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B16: Number systems

Unified State Exam in Computer Science: 2016 and beyond...
28
B16: Number systems
How many twos are there in ternary notation?
meaning of the number 9118 + 3123 – 27?
9118 = 3236
27 = 33
K.Yu. Polyakov, 2015
3236 + 3123 – 33
1
120 twos
http://kpolyakov.spb.ru

B16: Number systems

Unified State Exam in Computer Science: 2016 and beyond...
29
B17: Search engine queries
Request
USA | Japan | China
Japan | China
(USA & Japan) | (USA & China)
USA
A = USA
Request
A|B
B
A&B
A
Pages
450
260
50
?
B = Japan | China
Pages
450
260
50
?
A
A&B
B
NА | B = NA + NB – NA & B
NA = 450 – 260 + 50 = 240
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B17: Search engine queries

Unified State Exam in Computer Science: 2016 and beyond...
30
P = and Q = . Please indicate the smallest
possible length of a segment A such that the expression
(x P) (((x Q) (x A)) (x P))
identically true, that is, equal to 1 for any
the value of the variable x.
P(xP),
Q (x Q),
A (x A)
P (Q A P)
P (Q A P)
P Q A P P Q A
P Q A
P
Q
K.Yu. Polyakov, 2015
P
37
40
60
77
x
20
Q
http://kpolyakov.spb.ru

B18: logical operations, sets

Unified State Exam in Computer Science: 2016 and beyond...
31

Set A: integers. Expression
(x (2, 4, 6, 8, 10, 12)) → (((x (4, 8, 12, 116))
¬(x A)) → ¬(x (2, 4, 6, 8, 10, 12)))
true for any value of x. Define
the smallest possible value of the sum of elements
sets A.
P x (2, 4, 6, 8, 10, 12),
Q x (4, 8, 12, 116),
A x A
P (Q A P)
P Q A
Amin P Q P Q (4, 8, 12)
K.Yu. Polyakov, 2015
= 24
http://kpolyakov.spb.ru

B18: logical operations, sets

Unified State Exam in Computer Science: 2016 and beyond...
32
B18: logical operations, sets

(x&49<>0) ((x & 33 = 0) (x & A<> 0))


P x & 49 0,
A x & A 0
P(QA)
Q x & 33 0,
P (Q A) P Q A
P Q A (P Q) A
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B18: logical operations, sets

Unified State Exam in Computer Science: 2016 and beyond...
33
B18: logical operations, sets
"&" is a bitwise conjunction (AND). Expression
(x&49<>0) ((x & 33 = 0) (x & A<> 0))
true for any natural x. Define
the smallest possible value of A.
x&49
bit number
5 4 3 2 1 0
49 = 110001
X = abcdef
X & 49 = ab000f
x & 49 = 0 all bits (5, 4, 0) are zero
x&49<>
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B18: logical operations, sets

Unified State Exam in Computer Science: 2016 and beyond...
34
B18: logical operations, sets
"&" is a bitwise conjunction (AND). Expression
(x&49<>0) ((x & 33 = 0) (x & A<> 0))
true for any natural x. Define
the smallest possible value of A.
(PQ)A
P:x&49<>0 among the bits (5, 4, 0) there are non-zero
Q: x & 33 = 0 all bits (5, 0) are zero
bit number
5 4 3 2 1 0
33 = 100001
!
?
Bit 4 is non-zero!
K.Yu. Polyakov, 2015
What follows from this?
Amin = 24 = 16
http://kpolyakov.spb.ru

B18: logical operations, sets

Unified State Exam in Computer Science: 2016 and beyond...
35
B18: logical operations, sets
"&" is a bitwise conjunction (AND). Expression
(x&A<>0) ((x & 20 = 0) (x & 5<> 0))
true for any natural x. Define

P x & 20 0,
A x & A 0
A (P Q)
Q x & 5 0,
A (P Q) A P Q
P Q A (P Q) A
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B18: logical operations, sets

Unified State Exam in Computer Science: 2016 and beyond...
36
B18: logical operations, sets
"&" is a bitwise conjunction (AND). Expression
(x&A<>0) ((x & 20 = 0) (x & 5<> 0))
true for any natural x. Define
the highest possible value of A.
(PQ)A
P: x & 20 = 0 all bits (4, 2) are zero
Q: x & 5 = 0 all bits (2, 0) are zero
!
The bits (4, 2, 0) in x are zero!
Amax = 24 + 22 + 20 = 21
K.Yu. Polyakov, 2015
They will reset
bits of a number
at &!
http://kpolyakov.spb.ru

B18: logical operations, sets

Unified State Exam in Computer Science: 2016 and beyond...
37
B19: Array Processing

c:= 0;
for i:= 1 to 9 do
if A< A[i] then begin
c:= c + 1;
t:= A[i];
pair reversal
A[i]:= A; when sorting
A:=t
bubble
end;

K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B19: Array Processing

Unified State Exam in Computer Science: 2016 and beyond...
38
B19: Array Processing
1)
2)
3)
4)
5)
6)
6
9
9
9
9
9
9
9
6
7
7
7
7
7
7
7
6
6
6
6
6
2
2
2
2
2
2
2
1
1
1
5
5
5
5
5
5
5
1
1
1
1
0
0
0
0
3
3
3
3
3
3
3
0
4
4
4
4
4
4
4
0
8
8
8
8
8
8
8
0
c=6
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B19: Array Processing

Unified State Exam in Computer Science: 2016 and beyond...
39
B19: Array Processing
An array with indices from 0 to 9.
c:= 0;
for i:= 1 to 9 do
if A[i]< A then begin
c:= c + 1;
t:= A[i];
A[i]:= A;
pair reversal
A:=t
end;
What value will the variable "c" have?
4 7 3 8 5 0 1 2 9 6
4 7 3 8 5 0 1 2 9 6
4 7 3 8 5 0 1 2 9 6
K.Yu. Polyakov, 2015
c=2
http://kpolyakov.spb.ru

B19: Array Processing

Unified State Exam in Computer Science: 2016 and beyond...
40
B19: Array Processing

s:=0;
n:=10;
for i:=0 to n-1 do begin
s:=s+A[i]-A
end;


s:=A-A+A-A+A-...
+A-A+A-A+A-A
max = 999 – 100 = 899
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B19: Array Processing

Unified State Exam in Computer Science: 2016 and beyond...
41
B19: Array Processing
An array with indexes from 0 to 10.
s:=0;
n:=10;
for i:=0 to n-2 do begin
s:=s+A[i]-A
end;
The array contained three-digit natural numbers.
Which highest value can it have an "s"?
s:=A-A+A-A+A-...
+A-A+A-A+A-A
max = 999 + 999 – 100 – 100 = 1798
1798
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B19: Array Processing

Unified State Exam in Computer Science: 2016 and beyond...
42
B20: loops and conditions (“learn the algorithm”)
Specify the smallest five-digit number x for which
6 will be printed first and then 3.
a:= 0;
Minimum and maximum!
b:= 10;
readln(x);
while x > 0 do begin
y:= x mod 10;
x:= x div 10;
33336
if y > a then a:= y;
if y< b then b:= y;
end;
writeln(a); (maximum figure)
writeln(b); (minimum figure)
!
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B20: loops and conditions (“learn the algorithm”)

Unified State Exam in Computer Science: 2016 and beyond...
43
B20: cycles and conditions
Give the smallest number x greater than 100 for which
26 will be printed.
var x, L, M: integer;
begin
x odd: GCD(x,65) = 26
readln(x);
x even: GCD(x,52) = 26
L:=x; M:= 65;
if L mod 2 = 0 then x is divided by 26,
M:= 52;
not divisible by 52!
while L<>Mdo
gcd(104.52) = 52
104
if L > M then
L:= L - M
Answer: 130
else
M:= M – L;
writeln(M);
Euclid's algorithm!
end.
!
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B20: cycles and conditions

Unified State Exam in Computer Science: 2016 and beyond...
44
B21: Cycles and Procedures



begin
i
f(i)
f:= n*(n-1)+10
1
10
end;

2
12
readln(k);
3
16
i:= 0;
4
22
while f(i)< k do
5
30
36
i:= i + 1;
writeln(i);
6
40
Stop: k<= f(i)
31 … 40
10
K.Yu. Polyakov, 2015
?
For k = 30?
23 … 30
8
http://kpolyakov.spb.ru

B21: Cycles and Procedures

Unified State Exam in Computer Science: 2016 and beyond...
45
B21: Cycles and Procedures
Find the number of different values ​​of k for which
the program gives the same answer as with k = 36.
function f(n: longint): longint;
begin
Stop:
f:= n*(n-1)+10
f(i-1)< k <= f(i)
end;
(i-1)*(i-2)+10< k <= i*(i-1)+10

i2-3i+12< k <= i2-i+10
readln(k);
i:= 0;
i=6: 30< k <= 40
while f(i)< k do
31 … 40
i:= i + 1;
writeln(i);
Answer: 10
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B21: Cycles and Procedures

Unified State Exam in Computer Science: 2016 and beyond...
46
B21: Cycles and Procedures
Find the smallest value of k at which
the program produces the same answer as with k = 10.
def f(n):
Stop:
return n*n*n
f(i-1)< g(k) <= f(i)
def g(n):
(i-1)3< 2k+3 <= i3
return 2*n+3
3 < 23 <= i3
k=10:
(i-1)
k = int(input())
i=3
i = 1
while f(i)< g(k):
8 < 2k+3 <= 27
i+=1
3 … 12
print(i)
Answer: 3
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

B21: Cycles and Procedures

Unified State Exam in Computer Science: 2016 and beyond...
47
B22: programs for performers
1) add 1
2) multiply by 2
How many programs are there for which from the number 2
the number 29 is obtained and the trajectory of calculations is
contains the number 14 and does not contain the number 25?
N odd
K N 1
Recurrence formula: K N
K N 1 K N / 2 N even
1
2
3
4
5
6
7
8
9
10
11
12
13
14
1
1
1
2
2
3
3
5
5
7
7
10
10
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
13
13
13
13
13
13
13
13
13
13
13
0
0
0
13
13
new start
K.Yu. Polyakov, 2015
you can't come here
http://kpolyakov.spb.ru

B22: programs for performers

Unified State Exam in Computer Science: 2016 and beyond...
48
C24: bug fixes
A natural number x is read, you need to find it
the number of significant digits in its binary notation.
readln(x);
c:= 0;
while x > 0 do begin
c:= c + x mod 2;
x:= x div 10
end;
writeln(c)
1)
2)
3)
4)
?
?
What does he count?
When it works
right?
Only for x=1
invalid initial value
invalid loop condition
incorrect change of variables
wrong conclusion
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

C24: bug fixes

Unified State Exam in Computer Science: 2016 and beyond...
49
C24: bug fixes
We need to write a program that displays
the maximum digit of a number that is a multiple of 3. If the number does not contain
numbers that are multiples of 3, you need to display “NO” on the screen.
-1
readln(N);
maxDigit:= N mod 10;
When it works
while N > 0 do begin
right?
digit:= N mod 10;
if digit mod 3 1)=last
0 then the digit is divisible by 3
if digit > maxDigit
then
2) last
the figure is less than
maxDigit:= required
digit;result
N:= N div 10;
-1
end;
if maxDigit = 0 then writeln("NO")
else writeln(maxDigit);
?
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

C24: bug fixes

Unified State Exam in Computer Science: 2016 and beyond...
50

For a given sequence of non-negative
of integers, you need to find the maximum
the product of its two elements, the numbers of which
differ by at least 8. Number of elements
sequences does not exceed 10,000.
Task A (2 points). O(N2) in time, O(N) in memory.
Task B (3 points). O(N) in time, O(N) in memory.
Task B (4 points). O(N) in time, O(1) in memory.
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

Unified State Exam in Computer Science: 2016 and beyond...
51
S27: difficult task for programming
Task A (2 points). The data is stored in an array.
var N: integer;
a: array of integer;
i, j, max: integer;
begin
readln(N);
for i:=1 to N do read(a[i]);
max:= -1;
for i:= 9 to N do
for j:= 1 to i-8 do
if (a[j]*a[i] > max) then
max:= a[j]*a[i];
writeln(max)
end.
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

C27: difficult programming task

Unified State Exam in Computer Science: 2016 and beyond...
52
C27: difficult programming task
Task B (3 points). Data in an array, O(N) time.
i-8
i
a[i]
m
accumulate!
max a[ j ] a[i] max a[ j ] a[i]
j
j
max:= 0;
m:= 0;
for i:= 9 to N do begin
if a > m then m:= a;
if m*a[i] > max then max:= m*a[i];
end;
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

C27: difficult programming task

Unified State Exam in Computer Science: 2016 and beyond...
53
C27: difficult programming task

i-8
i
store in an array
var a: array of integer;
x
Initial array filling:
for i:=1 to 8 do read(a[i]);
Promotion:
for i:=1 to 7 do
a[i]:=a;
a:=x;
K.Yu. Polyakov, 2015
!
It's a queue!
http://kpolyakov.spb.ru

C27: difficult programming task

Unified State Exam in Computer Science: 2016 and beyond...
54
C27: difficult programming task
Task B (4 points). Memory O(1), time O(N).
a
x
const d = 8; (shift)
... (have already read the first d pieces)
max:= 0;
m:= 0;
for i:=d+1 to N do begin
read(x);
if a > m then m:= a;
if m*x > max then max:= m*x;
for j:=1 to d-1 do
a[j]:= a;
a[d]:= x;
end;
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

C27: difficult programming task

Unified State Exam in Computer Science: 2016 and beyond...
55
C27: difficult programming task
Task B (4 points). Without shift (ring queue).
i 0
1
2
3
9
1
5
6
7
k
0
a
4
10
2 11
3 12
4 5
8
9
N-1
10 11 12 13 14 15 16 17 18
7
6
7
8
a:= data[i];
for i:=0 to d-1 do read(a[i]);
for i:=d to N-1 do begin
read(x);
k:= i mod d;
if a[k] > m then m:= a[k];
if m*x > max then max:= m*x;
a[k]:=x;
end;
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

C27: difficult programming task

Unified State Exam in Computer Science: 2016 and beyond...
56
C27: difficult programming task
Calculate the maximum even product of two
indications, between the moments of transmission of which
at least 8 minutes have passed.
x
support
1) the maximum of all
2) maximum even
x
even even * any
even any * even
K.Yu. Polyakov, 2015
store in an array
(queue)
http://kpolyakov.spb.ru

C27: difficult programming task

Unified State Exam in Computer Science: 2016 and beyond...
57
C27: difficult programming task
for i:=d to N-1 do begin
read(x);
k:= i mod d;
maximum
even
if a[k] > m then m:= a[k];
if ((a[k] mod 2 = 0) and
(a[k] > mEven)) then mEven:= a[k];
if x mod 2 = 1 then begin
received
odd
if mEven*x > max then
max:= mEven*x;
end
received
even
else
if m*x > max then max:= m*x;
a[k]:=x;
end;
K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru

C27: difficult programming task

Unified State Exam in Computer Science: 2016 and beyond...
58
conclusions
!
K.Yu. Polyakov, 2015
Variability!
http://kpolyakov.spb.ru

conclusions

Unified State Exam in Computer Science: 2016 and beyond...
59
The end of the film
POLYAKOV Konstantin Yurievich
Doctor of Technical Sciences, computer science teacher
GBOU secondary school No. 163, St. Petersburg

K.Yu. Polyakov, 2015
http://kpolyakov.spb.ru
Have questions?

Report a typo

Text that will be sent to our editors: