32768
Объяснение:
Данная незамысловатая функция Excel VBA формирует строку, согласно условию.
Function replstr(str As String, n As Integer) As String
Dim a(1 To 3), b(1 To 3) As String, i, j As Integer
a(1) = "A": a(2) = "B": a(3) = "AB"
b(1) = "AB": b(2) = "AB": b(3) = "A"
For i = 1 To n
j = (i - 1) Mod 3 + 1
str = Replace(str, a(j), b(j))
Next
replstr = str
End Function
Аргументы функции:
1) Исходная строка (а данном случае “AA”)
2) Число операций с исходной строкой
Значение первых 13 операций:
=replstr("AA";1) ABAB
=replstr("AA";2) AABAAB
=replstr("AA";3)
=replstr("AA";4) ABABABAB
=replstr("AA";5) AABAABAABAAB
=replstr("AA";6)
=replstr("AA";7) ABABABABABABABAB
=replstr("AA";8) AABAABAABAABAABAABAABAAB
=replstr("AA";9)
=replstr("AA";10)
=replstr("AA";11)
=replstr("AA";12)
=replstr("AA";13)
Для подсчета символов “A” в строке, используем еще одну функцию:
Function chrcount(str1 As String, str2 As String) As Integer
Dim str() As String
str = Split(str1, str2)
chrcount = UBound(str, 1)
End Function
Аргументы функции:
1) Cтрока
2) Символ (последовательность символов), число которых требуется найти
Например, результатом использования функции =chrcount(replstr("AA";20);"A") в ячейке Excel будет число 256
Используя описанные функции, посчитаем символы “A”в первых 13 строках
Номер операции (i) Число символов “A” в строке
1 2
2 4
3 4
4 4
5 8
6 8
7 8
8 16
9 16
10 16
11 32
12 32
13 32
Как видно из таблицы, число символов в строке образует числовую последовательность 2^1; 2^2; 2^2; 2^2; 2^3; 2^3; 2^3; … 2^([(i-2)/3]+2)
Таким образом, мы получили формулу для вычисления числа символов “A”в строке по номеру операции.
Соответственно, 2^([(43-2)/3]+2) = 32768
date=int(input("Введите день рождения:"))
month=int(input("Введите месяц рождения:"))
year=int(input("Введите год рождения:"))
if (date>=21 and date<=31 and month==3) or( month==4 and date>=1 and date<=19):
print("Знак зодиака:Овен")
elif (date>=20 and date<=30 and month==4) or( month==5 and date>=1 and date<=20):
print("Знак зодиака:Телец")
elif (date>=21 and date<=31 and month==5) or( month==6 and date>=1 and date<=21):
print("Знак зодиака:Близнецы")
elif (date>=22 and date<=30 and month==6) or( month==7 and date>=1 and date<=22):
print("Знак зодиака:Рак")
elif (date>=23 and date<=31 and month==7) or( month==8 and date>=1 and date<=22):
print("Знак зодиака:Лев")
elif (date>=23 and date<=31 and month==8) or( month==9 and date>=1 and date<=22):
print("Знак зодиака:Дева")
elif (date>=23 and date<=30 and month==9) or( month==10 and date>=1 and date<=23):
print("Знак зодиака:Весы")
elif (date>=24 and date<=31 and month==10) or( month==11 and date>=1 and date<=22):
print("Знак зодиака:Скорпион")
elif (date>=23 and date<=30 and month==11) or( month==12 and date>=1 and date<=21):
print("Знак зодиака:Стрелец")
elif (date>=22 and date<=31 and month==12) or( month==1 and date>=1 and date<=20):
print("Знак зодиака:Козерог")
elif (date>=21 and date<=31 and month==1) or( month==2 and date>=1 and date<=18):
print("Знак зодиака:Водолей")
elif (date>=19 and date<=29 and month==2) or( month==3 and date>=1 and date<=20):
print("Знак зодиака:Рыбы")
#Пример входных данных
18
7
2002
Знак зодиака:Рак