Держи. На питоне
Объяснение:
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)
<html>
<body>
<table border="1" cellspacing="0" height="333" width="333">
<tr>
<td colspan="8"></td>
</tr>
<tr>
<td rowspan="6"></td>
<td colspan="6"></td>
<td rowspan="7"></td>
</tr>
<tr>
<td rowspan="4"></td>
<td colspan="4"></td>
<td rowspan="5"></td>
</tr>
<tr>
<td rowspan="2"></td>
<td colspan="2"></td>
<td rowspan="3"></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td colspan="5"></td>
</tr>
<tr>
<td colspan="7"></td>
</tr>
</table>
<br>
</body>
</html>
Объяснение:
картинка
#! /usr/bin/env python3
#! encoding: utf-8
def nod(a, b):
if a == 0:
return b
if b == 0:
return a
if a > b:
a = a % b
else:
b = b % a
return nod(a,b)
print( 'Введите два натуральных числа: ')
a = int( input())
b = int( input())
print( 'НОД(',a,', ',b,') = ', end = '')
print(nod(a,b))
Результат: