1.煤球数目
代码
python
cnt = ans = 0
start = 1
a = []
while cnt<100:
ans+=start
start += 1
t = ans+start
cnt+=1
a.append(ans)
print(sum(a))
2.奖券数目
代码
python
def f(x)->bool:
while x:
if x%10==4:
return False
x//=10
return True
ans = 0
for i in range(10000,100000):
if f(i):
ans+=1
print(ans)
3.网友年龄
代码
python
def f(x):
return int(str(x)[::-1])
ans=0
for i in range(10,100):
if f(i)==i-27:
ans+=1
print(ans)
4.方程整数解
代码
python
for i in range(1,33):
for j in range(i,33):
for k in range(j,33):
if i*i+j*j+k*k==1000 and min(i,j,k)!=6:
print(min(i,j,k))
5.回家路费
代码
python
i = cnt =1
t = 2
while i < 108:
i += t
t +=2
cnt+=1
print(cnt)
6. 质数
代码
python
def f(x)->bool:
for i in range(2,x//2+1):
if x%i==0:
return False
return True
ans=[2]
for i in range(3,20000):
if f(i):
ans.append(i)
if len(ans)==2019:
break
print(ans[-1])
7.猜年龄
代码
python
ans=[]
for i in range(1,30):
for j in range(i,30):
if i*j//(i+j)==6 and j-i<=8:
ans.append(i)
print(ans[0])