20251215 2.4
This commit is contained in:
parent
feecc004dd
commit
7c4ef278a1
8
lesson2.4_1.py
Normal file
8
lesson2.4_1.py
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Таблица умножения.
|
||||||
|
'''
|
||||||
|
size = int(input())
|
||||||
|
for row in range(1, size + 1):
|
||||||
|
for col in range(1, size + 1):
|
||||||
|
print(row * col, end=" ")
|
||||||
|
print()
|
||||||
8
lesson2.4_10.py
Normal file
8
lesson2.4_10.py
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Мы делили апельсин.
|
||||||
|
'''
|
||||||
|
for a in range(1, (b := int(input())) - 1):
|
||||||
|
if a == 1:
|
||||||
|
print('А Б В')
|
||||||
|
for c in range(1, b - a):
|
||||||
|
print(f'{a} {c} {b - a - c}')
|
||||||
17
lesson2.4_11.py
Normal file
17
lesson2.4_11.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Простая задача 3.0.
|
||||||
|
'''
|
||||||
|
count = 0
|
||||||
|
for i in range(int(input())):
|
||||||
|
j = 2
|
||||||
|
if (n := int(input())) > 1:
|
||||||
|
count += 1
|
||||||
|
if n == 2:
|
||||||
|
count += 1
|
||||||
|
while n % j:
|
||||||
|
if j > n ** 0.5:
|
||||||
|
break
|
||||||
|
j += 1
|
||||||
|
else:
|
||||||
|
count -= 1
|
||||||
|
print(count)
|
||||||
11
lesson2.4_12.py
Normal file
11
lesson2.4_12.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Числовой прямоугольник.
|
||||||
|
'''
|
||||||
|
m, n = int(input()), int(input())
|
||||||
|
width = len(str(m * n))
|
||||||
|
for i in range(1, m + 1):
|
||||||
|
for j in range(n * (i - 1) + 1, n * i + 1):
|
||||||
|
if j == n * i:
|
||||||
|
print(str(j).rjust(width, ' '))
|
||||||
|
else:
|
||||||
|
print(str(j).rjust(width, ' '), end=' ')
|
||||||
11
lesson2.4_13.py
Normal file
11
lesson2.4_13.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Числовой прямоугольник 2.0.
|
||||||
|
'''
|
||||||
|
m, n = int(input()), int(input())
|
||||||
|
width = len(str(m * n))
|
||||||
|
for i in range(1, m + 1):
|
||||||
|
for j in range(i, i + m * (n - 1) + 1, m):
|
||||||
|
if j == i + m * (n - 1):
|
||||||
|
print(str(j).rjust(width, ' '))
|
||||||
|
else:
|
||||||
|
print(str(j).rjust(width, ' '), end=' ')
|
||||||
18
lesson2.4_14.py
Normal file
18
lesson2.4_14.py
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Числовая змейка.
|
||||||
|
'''
|
||||||
|
m, n = int(input()), int(input())
|
||||||
|
width = len(str(m * n))
|
||||||
|
for i in range(1, m + 1):
|
||||||
|
if i % 2:
|
||||||
|
for j in range(n * (i - 1) + 1, n * i + 1):
|
||||||
|
if j == n * i:
|
||||||
|
print(str(j).rjust(width, ' '))
|
||||||
|
else:
|
||||||
|
print(str(j).rjust(width, ' '), end=' ')
|
||||||
|
else:
|
||||||
|
for j in range(n * i, n * (i - 1), -1):
|
||||||
|
if j == n * (i - 1) + 1:
|
||||||
|
print(str(j).rjust(width, ' '))
|
||||||
|
else:
|
||||||
|
print(str(j).rjust(width, ' '), end=' ')
|
||||||
15
lesson2.4_15.py
Normal file
15
lesson2.4_15.py
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Числовая змейка 2.0.
|
||||||
|
'''
|
||||||
|
m, n = int(input()), int(input())
|
||||||
|
width = len(str(m * n))
|
||||||
|
for i in range(1, m + 1):
|
||||||
|
for j in range(n):
|
||||||
|
if not j % 2 and j != n - 1:
|
||||||
|
print(str(i + 2 * m * (j // 2)).rjust(width, ' '), end=' ')
|
||||||
|
elif not j % 2 and j == n - 1:
|
||||||
|
print(str(i + 2 * m * (j // 2)).rjust(width, ' '))
|
||||||
|
elif j % 2 and j != n - 1:
|
||||||
|
print(str(2 * m * (j // 2 + 1) - (i - 1)).rjust(width, ' '), end=' ')
|
||||||
|
else:
|
||||||
|
print(str(2 * m * (j // 2 + 1) - (i - 1)).rjust(width, ' '))
|
||||||
12
lesson2.4_16.py
Normal file
12
lesson2.4_16.py
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Редизайн таблицы умножения.
|
||||||
|
'''
|
||||||
|
m, n = int(input()), int(input())
|
||||||
|
for i in range(1, m + 1):
|
||||||
|
for j in range(1, m + 1):
|
||||||
|
if j != m:
|
||||||
|
print(f'{(str(i * j) + " " if n % 2 else str(i * j)).center(n)}|', end='')
|
||||||
|
else:
|
||||||
|
print(f'{(str(i * j) + " " if n % 2 else str(i * j)).center(n)}')
|
||||||
|
if i * j != m * m:
|
||||||
|
print(f'{"-"* ((n + 1) * m - 1)}')
|
||||||
8
lesson2.4_17.py
Normal file
8
lesson2.4_17.py
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*А роза упала на лапу Азора 3.0.
|
||||||
|
'''
|
||||||
|
count = 0
|
||||||
|
for _ in range(int(input())):
|
||||||
|
if (n := input()) == n[::-1]:
|
||||||
|
count += 1
|
||||||
|
print(count)
|
||||||
17
lesson2.4_18.py
Normal file
17
lesson2.4_18.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Новогоднее настроение 2.0.
|
||||||
|
'''
|
||||||
|
m, lengths = '', [0]
|
||||||
|
for j in range(1, (x := int(input())) + 1):
|
||||||
|
m += str(j) + ' '
|
||||||
|
if j in (sum(range(i)) for i in range(j + 2)):
|
||||||
|
lengths.append(len(m) - 1)
|
||||||
|
m = ''
|
||||||
|
lengths.append(len(m) - 1)
|
||||||
|
n = 1
|
||||||
|
for z in range(1, x + 1):
|
||||||
|
if z - 1 in (sum(range(i)) for i in range(z + 2)):
|
||||||
|
print(f"{' ' * ((max(lengths) - lengths[n]) // 2)}{z}", end=' ' if z != 1 else '\n')
|
||||||
|
n += 1
|
||||||
|
else:
|
||||||
|
print(z, end='\n' if z in (sum(range(i)) for i in range(z + 2)) else ' ')
|
||||||
9
lesson2.4_19.py
Normal file
9
lesson2.4_19.py
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Числовой квадрат.
|
||||||
|
'''
|
||||||
|
n = int(input())
|
||||||
|
m = len(str((n + 1) // 2))
|
||||||
|
for i in range(n):
|
||||||
|
for j in range(n):
|
||||||
|
print(f'{min(i + 1, j + 1, n - i, n - j):>{m}}', end=' ')
|
||||||
|
print()
|
||||||
7
lesson2.4_2.py
Normal file
7
lesson2.4_2.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Не таблица умножения.
|
||||||
|
'''
|
||||||
|
size = int(input())
|
||||||
|
for second in range(1, size + 1):
|
||||||
|
for first in range(1, size + 1):
|
||||||
|
print(f'{first} * {second} = {first * second}')
|
||||||
16
lesson2.4_20.py
Normal file
16
lesson2.4_20.py
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Математическая выгода.
|
||||||
|
'''
|
||||||
|
number = int(input())
|
||||||
|
best_value = 0
|
||||||
|
best_base = 0
|
||||||
|
for base in range(10, 1, -1):
|
||||||
|
summa = 0
|
||||||
|
num = number
|
||||||
|
while num > 0:
|
||||||
|
summa += (num % base)
|
||||||
|
num //= base
|
||||||
|
if summa >= best_value:
|
||||||
|
best_value = summa
|
||||||
|
best_base = base
|
||||||
|
print(best_base)
|
||||||
14
lesson2.4_3.py
Normal file
14
lesson2.4_3.py
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Новогоднее настроение.
|
||||||
|
'''
|
||||||
|
count = int(input())
|
||||||
|
num = 1
|
||||||
|
row = 2
|
||||||
|
print(num)
|
||||||
|
while num < count:
|
||||||
|
for i in range(1, row + 1):
|
||||||
|
if num + i <= count:
|
||||||
|
print(num + i, end=" ")
|
||||||
|
row += 1
|
||||||
|
print()
|
||||||
|
num = num + row - 1
|
||||||
7
lesson2.4_4.py
Normal file
7
lesson2.4_4.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Суммарная сумма.
|
||||||
|
'''
|
||||||
|
summ = 0
|
||||||
|
for _ in range(int(input())):
|
||||||
|
summ += sum(map(int, list(input())))
|
||||||
|
print(summ)
|
||||||
12
lesson2.4_5.py
Normal file
12
lesson2.4_5.py
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Зайка — 5.
|
||||||
|
'''
|
||||||
|
counter, temp = 0, 0
|
||||||
|
for _ in range(int(input())):
|
||||||
|
while (x := input()) != 'ВСЁ':
|
||||||
|
if x == 'зайка':
|
||||||
|
temp += 1
|
||||||
|
if temp:
|
||||||
|
counter += 1
|
||||||
|
temp = 0
|
||||||
|
print(counter)
|
||||||
9
lesson2.4_6.py
Normal file
9
lesson2.4_6.py
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*НОД 2.0.
|
||||||
|
'''
|
||||||
|
n, a = int(input()), int(input())
|
||||||
|
for _ in range(n - 1):
|
||||||
|
b = int(input())
|
||||||
|
while b:
|
||||||
|
a, b = b, a % b
|
||||||
|
print(a)
|
||||||
7
lesson2.4_7.py
Normal file
7
lesson2.4_7.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*На старт! Внимание! Марш!
|
||||||
|
'''
|
||||||
|
for i in range(int(input())):
|
||||||
|
for j in range(3 + i, 0, -1):
|
||||||
|
print(f'До старта {j} секунд(ы)')
|
||||||
|
print(f'Старт {i + 1}!!!')
|
||||||
9
lesson2.4_8.py
Normal file
9
lesson2.4_8.py
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Максимальная сумма.
|
||||||
|
'''
|
||||||
|
name, summ = '', 0
|
||||||
|
for _ in range(int(input())):
|
||||||
|
temp_name, temp_summ = input(), sum(map(int, input()))
|
||||||
|
if temp_summ >= summ:
|
||||||
|
name, summ = temp_name, temp_summ
|
||||||
|
print(name)
|
||||||
7
lesson2.4_9.py
Normal file
7
lesson2.4_9.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
'''****** Задание ********
|
||||||
|
*Большое число.
|
||||||
|
'''
|
||||||
|
number = ''
|
||||||
|
for _ in range(int(input())):
|
||||||
|
number += max(input())
|
||||||
|
print(number)
|
||||||
Loading…
Reference in a new issue