Держи. На питоне
Объяснение:
n = int(input())
cool_score = 0
jumps = input().split()
sorted_jumps = sorted(jumps)
for i in range(len(jumps)):
if i != len(jumps) - 1:
Ni = jumps.index(sorted_jumps[i]) + 1
Hi = sorted_jumps[i]
if jumps.count(jumps[i]) > 1:
jumps[i] = 'done'
Nj = jumps.index(sorted_jumps[i + 1]) + 1
Hj = sorted_jumps[i + 1]
a = 'abs({} - {}) + {} - {}'.format(int(Ni), int(Nj), int(Hj), int(Hi))
cool_score += eval(a)
print(cool_score)
PascalABC.NET
#1
function Y(x:integer) := 2*((x+2)**2)+5.5*(x+2) - 3;
begin
var Xes := Range(3, 25);
Xes.Tabulate(p -> Y(p)).Println;
end.
#2
const PASS = '123ab';
var rpass := Readstring('Pass: ');
while rpass <> PASS do begin
rpass := Readstring('Wrong pass. Try again: ');
end;
print('Correct password. Welcome');
#3
//Сначала читаем цифру, которую надо удалить, а уже потом число.
var X := ReadChar();
var number := ReadInteger().ToString.ToCharArray.ToList;
while number.Contains(X) do number.Remove(X);
number.JoinIntoString.Println;
#4
var X := ReadInteger();
Print((x div 100)+(x mod 100));
Держи. На питоне
Объяснение:
n = int(input())
cool_score = 0
jumps = input().split()
sorted_jumps = sorted(jumps)
for i in range(len(jumps)):
if i != len(jumps) - 1:
Ni = jumps.index(sorted_jumps[i]) + 1
Hi = sorted_jumps[i]
if jumps.count(jumps[i]) > 1:
jumps[i] = 'done'
Nj = jumps.index(sorted_jumps[i + 1]) + 1
Hj = sorted_jumps[i + 1]
a = 'abs({} - {}) + {} - {}'.format(int(Ni), int(Nj), int(Hj), int(Hi))
cool_score += eval(a)
print(cool_score)
PascalABC.NET
#1
function Y(x:integer) := 2*((x+2)**2)+5.5*(x+2) - 3;
begin
var Xes := Range(3, 25);
Xes.Tabulate(p -> Y(p)).Println;
end.
#2
const PASS = '123ab';
begin
var rpass := Readstring('Pass: ');
while rpass <> PASS do begin
rpass := Readstring('Wrong pass. Try again: ');
end;
print('Correct password. Welcome');
end.
#3
begin
//Сначала читаем цифру, которую надо удалить, а уже потом число.
var X := ReadChar();
var number := ReadInteger().ToString.ToCharArray.ToList;
while number.Contains(X) do number.Remove(X);
number.JoinIntoString.Println;
end.
#4
begin
var X := ReadInteger();
Print((x div 100)+(x mod 100));
end.
Объяснение: