program a2;
var
a, x1, y1, z1, l1, z, l: string;
i, g, d, f, a1, b1, sum, vr, vr1, err: int64;
begin
readln(a);
g := pos(';', a);
x1 := copy(a, 2, g - 2);
y1 := copy(a, g + 2, length(a) - g - 2);
if a[1] = '[' then d := 1
else d := 0;
if a[length(a)] = ']' then f := 1
else f := 0;
if pos('/', x1) <> 0 then begin
z := copy(x1, 1, pos('/', x1) - 1);
z1 := copy(x1, pos('/', x1) + 1, length(x1) - pos('/', x1));
val(z, vr, err);
val(z1, vr1, err);
a1 := vr div vr1;
end
else val(x1, a1, err);
if pos('/', y1) <> 0 then begin
l := copy(y1, 1, pos('/', y1) - 1);
l1 := copy(y1, pos('/', y1) + 1, length(y1) - pos('/', y1));
val(l, vr, err);
val(l1, vr1, err);
b1 := vr div vr1;
else val(y1, b1, err);
for i := a1 to b1 do sum := sum + 1;
if (d = 0) then
if vr = 0 then sum := sum - 1
else if (vr mod vr1 = 0) then sum := sum - 1;
if (f = 0) then
writeln(sum);
end.
На не благодари)
from random import random
N = 10
a = []
for i in range(N):
b = int(random() * 50)
a.append(b)
print(a)
min = 101
for i in range(N-1):
s = a[i]+a[i+1]
if (s < min) and (s % 2 == 1):
min=s
print(min)
Пример:[41, 35, 16, 7, 29, 9, 16, 28, 10, 6]
23
2)
from random import random
N = 10
a = []
for i in range(N):
b = int(random() * 50)-25
a.append(b)
print(a)
k = 0
for i in range(N-1):
p = a[i]*a[i+1]
s = a[i]+a[i+1]
if (p % 2 != 0) and (s > 0):
k = k+1
print(k)
Пример:[11, 23, 12, -16, 21, 15, -11, -10, 10, 17]
3
program a2;
var
a, x1, y1, z1, l1, z, l: string;
i, g, d, f, a1, b1, sum, vr, vr1, err: int64;
begin
readln(a);
g := pos(';', a);
x1 := copy(a, 2, g - 2);
y1 := copy(a, g + 2, length(a) - g - 2);
if a[1] = '[' then d := 1
else d := 0;
if a[length(a)] = ']' then f := 1
else f := 0;
if pos('/', x1) <> 0 then begin
z := copy(x1, 1, pos('/', x1) - 1);
z1 := copy(x1, pos('/', x1) + 1, length(x1) - pos('/', x1));
val(z, vr, err);
val(z1, vr1, err);
a1 := vr div vr1;
end
else val(x1, a1, err);
if pos('/', y1) <> 0 then begin
l := copy(y1, 1, pos('/', y1) - 1);
l1 := copy(y1, pos('/', y1) + 1, length(y1) - pos('/', y1));
val(l, vr, err);
val(l1, vr1, err);
b1 := vr div vr1;
end
else val(y1, b1, err);
for i := a1 to b1 do sum := sum + 1;
val(z, vr, err);
val(z1, vr1, err);
if (d = 0) then
if vr = 0 then sum := sum - 1
else if (vr mod vr1 = 0) then sum := sum - 1;
val(l, vr, err);
val(l1, vr1, err);
if (f = 0) then
if vr = 0 then sum := sum - 1
else if (vr mod vr1 = 0) then sum := sum - 1;
writeln(sum);
end.
На не благодари)