num = 0
for i in range(2021):
for j in str(i):
if j == '2':
num += 1
print(num)
num = 0
for i in range(1, 2021): #取分子
for j in range(1, 2021): #取分母
while True: #辗转相除法
if i % j == 0:
m = j
break
else:
k = i % j
i = j
j = k
if m == 1: #判断最大公约数是不是1
num += 1
print(num)
#不难看出每次加的数是递增的且d为4
#1 + 4 = 5
#5 + 4 + 4 = 13
#13 + 4 + 4 + 4 = 25
#可以预测
i = 1
a = 0
b = 1
while i < 20:
a += 4
b += a
i += 1
print(b)
def isweekmonth(day): #判断月初是不是星期一
day = day -2
x = day % 7
if x == 0:
return 1
else:
return 0
weekmonth = 0
day = 0
for year in range(2000, 2021): #计算天数
for month in range(1, 13):
if month in [1, 3, 5, 7, 8, 10, 12]:
day = day + 31
weekmonth = weekmonth + isweekmonth(day)
elif month in [4, 6, 9, 11]:
day = day + 30
weekmonth = weekmonth + isweekmonth(day)
elif (year % 4 == 0 and year % 100 != 0 or year % 400 == 0) and month == 2:
day = day + 29
weekmonth = weekmonth + isweekmonth(day)
elif (year % 4 != 0 and year % 100 == 0 or year % 400 != 0) and month == 2:
day = day + 28
weekmonth = weekmonth + isweekmonth(day)
print(day) #7671
runsum = (day - 91) + (day - 93) // 7 + ((2020 - 2000) * 12 - 2) - weekmonth
# 总路程 = 天数 + 每星期一多跑的 + 每个月初多跑的 -月初是星期一的天数
print(runsum)
#不会
j = 0
y = 0
n = int(input())
for i in range(n):
grade = float(input())
if grade >= 60:
j += 1
if grade >= 85:
y += 1
print(int(round(j / n, 2) * 100), end="")
print("%")
print(int(round(y / n, 2) * 100), end="")
print("%")
def get_year(year, mod):
year = str(year + 1) #取下一年
raey = year[::-1] #取年份反过来的月份和日期
month = int(raey[:2]) #取年份反过来的月份
day = int(raey[2:]) #取年份反过来的日期
y = int(year) #把年变成int型方便计算是不是闰年
if month in C: #判断反过来的月份是不是合法的
if y % 4 == 0 and y % 100 != 0 or y % 400 == 0: #判断是不是闰年
if day <= A[month]: #判断反过来的日期是不是合法的
yearmod(mod, raey, year)
else:
get_year(int(year), mod) #月份不是合法的就到下一年
else: #不是闰年
if day <= B[month]:
yearmod(mod, raey, year)
else:
get_year(int(year), mod) #日期不是合法的就到下一年
else:
get_year(int(year), mod) #月份不是合法的就到下一年
def yearmod(mod, raey, year):
if mod == 1: #mod1是简单回文
print(year + raey)
elif mod == 2: #mod2是ABABBABA式的
if year[:2] == year[2:]:
print(year + raey)
else:
get_year(int(year), mod)
A = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] #闰年的每月天数
B = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] #一般年的每月天数
C = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] #每年的月数
time = (str(input())) #取时间
get_year(int(time[:4]), mod=1)
get_year(int(time[:4]), mod=2)
a = ['a', 'b', 'a', 'b', 'c']
sum = 0
for i in range(len(a)):
for j in range(1, len(a)+1-i): #这两个循环来取出所有情况
b = [] #这个用来记录已经记录过的字母
for k in a[i:i+j]:
index = ord(k) - ord('a') #这个循环来判断是否重复
if index in b:
continue
else:
b.append(index)
sum = sum + 1
print(sum)
n = int(input())
lines = []
for i in range(n):
a, b = list(map(int, input().split()))
lines.append((a, b)) #保存所有直线
lines = list(set(lines)) #删除重复直线
n = len(lines)
linepoint = [1] * (n + 1) #用来记录一个直线贡献了多少平面
point = set() #创建一个记录交点的集合
for i in range(1, n):
for j in range(i): #逐渐加边,并把新增的边和之前的边两两求交点
line1 = lines[i]
line2 = lines[j]
a1 = line1[0]
b1 = line1[1]
a2 = line2[0]
b2 = line2[1]
if a1 - a2 == 0: #平行就没有交点就换下一组
continue
else:
x = (b2 - b1) / (a1 - a2)
y = a1 * x + a1
x = round(x, 5)
y = round(y, 5)
point.add((x, y)) #有交点就记录交点
linepoint[i] += len(point) #把有交点而且不是重复交点的多贡献的1个平面加上
sum = 0
for i in linepoint[:n]:
sum += int(i)
print(sum + 1) #最后要加上没有直线时最开始就有的一个平面
#不会