This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Сколькими способами можно выбрать на квадратной шахматной доске | |
# со стороной, равной k, белое и черное поля, | |
# не лежащие на одной горизонтали или одной вертикали? | |
k=int(input('Введите длину стороны доски: ')) | |
while k<1: | |
print('Длина должна выражаться натуральным числом') | |
k=int(input('Введите длину стороны доски: ')) | |
i=0 | |
for g1 in range (1, k+1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Даны два двузначных числа – X и Y. Известно, что | |
# одна цифра числа Y равна сумме, а другая – разности цифр числа X. | |
# Найти все пары таких чисел. | |
for k in range (10, 100): | |
for n in range (10, 100): | |
if (k//10==n//10+n%10 and (k%10==n//10-n%10 or k%10==n%10-n//10) | |
or k%10==n//10+n%10 and (k//10==n//10-n%10 or k//10==n%10-n//10)): | |
print(k, n) # Выводим на экран искомые пары. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Для каждого целого числа b от 2 до введённого числа, найти, | |
# сколько существует таких натуральных n, не превосходящих 2021, | |
# что сумма 1^n + 2^n + 3^n + 4^n делится на b. | |
m=int(input('Введите целое число, большее 1: ')) | |
while m<2: | |
print('Это число не больше 1.') | |
m=int(input('Введите целое число, большее 1: ')) | |
for b in range (2, m+1): | |
i=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Решение задачи «Яша плавает в бассейне» | |
N=int(input()) | |
M=int(input()) | |
x=int(input()) | |
y=int(input()) | |
if N>M: | |
a=[x, M-x, y, N-y] | |
print(min(a)) | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Назовём автобусный билет счастливым, | |
# если сумма цифр его номера делится на 7. | |
# Могут ли два билета подряд быть счастливыми? | |
def digsum(n): | |
sum=0 | |
while n>0: | |
dig=n%10 | |
sum+=dig | |
n=n//10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Вывести все точные степени, не превосходящие | |
# введённого пользователем числа. | |
k=int(input()) | |
d=0 | |
while 2**(d+1)<=k: | |
d+=1 | |
list=[] | |
for pow in range (2, d+1): | |
i=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Эта программа выводит все натуральные числа (из диапазона, заданного пользователем), | |
# у которых количество чётных цифр равно количеству | |
# нечётных, а количество простых цифр равно количеству составных | |
# (при этом подразумевается наличие хотя бы одной простой цифры). | |
a=int(input()) | |
b=int(input()) | |
for i in range(a, b+1): | |
k=i | |
even=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://math.hashcode.ru/questions/230427 | |
for i in range(10, 100): | |
k=0 | |
if i%3==0: | |
k+=1 | |
if i%4==0: | |
k+=1 | |
if i%5==0: | |
k+=1 | |
if i%9==0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Найдите наименьшее натуральное число, имеющее 16 различных делителей, | |
# но не делящееся ни на 3, ни на 5. | |
# Программка получила на входе 16 (желаемое количество делителей), | |
# 3 и 5 (два числа на которые искомое число не должно делиться). | |
def div(k): | |
count=0 | |
for i in range(1, k+1): | |
if k%i==0: | |
count+=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Задача №3534. Число сочетаний | |
def fac(num): | |
f=1 | |
for i in range(1, num+1): | |
f*=i | |
return f | |
n=int(input()) | |
k=int(input()) | |
if k>n: | |
print(0) |
OlderNewer