赞
踩
题目很好,是我太菜了,呜呜呜
就放点题目了,题解我不配
思路:打表找规律,周期应该是60
给出的那个数也正好是60的倍数,代码如下:
a = 1
b = 1
n = 202202011200
cnt = 0
for i in range(58):
c = a+b
if c % 10 == 7:
cnt += 1
a = b
b = c
res = cnt*(n//60)
print(res)
# 26960268160
思路:一边判断一边筛,结合python的字典
from math import * def isPrime(n): for i in range(2, int(sqrt(n))+1): if n % i == 0: return False return True dic = {} with open('primes.txt', 'r') as file: txt = file.readlines() cnt = 0 for num in txt: num = int(num[:-1]) if num in dic: if dic[num]: cnt += 1 else: if isPrime(num): cnt += 1 dic[num] = True else: dic[num] = False tmp = num*2 while tmp <= 10**8: dic[tmp] = False tmp += num print(cnt) print('end') # 342693
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。