蓝桥杯刷题(十三)

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])
相关推荐
摸鱼仙人~7 小时前
企业级 RAG 问答系统开发上线流程分析
后端·python·rag·检索
serve the people7 小时前
tensorflow tf.nn.softmax 核心解析
人工智能·python·tensorflow
癫狂的兔子7 小时前
【BUG】【Python】eval()报错
python·bug
啃火龙果的兔子7 小时前
java语言基础
java·开发语言·python
masterqwer7 小时前
day42打卡
python
不会飞的鲨鱼7 小时前
抖音验证码滑动轨迹原理(很难审核通过)
javascript·python
我命由我123457 小时前
Python 开发问题:No Python interpreter configured for the project
开发语言·后端·python·学习·pycharm·学习方法·python3.11
多米Domi0117 小时前
0x3f第12天 0-1背包
python·算法·leetcode·动态规划
我命由我123457 小时前
开发中的英语积累 P21:Parentable、Guideline、Manifest、Expire、Condition、Optimize
经验分享·笔记·学习·职场和发展·求职招聘·职场发展·学习方法
电商API&Tina7 小时前
跨境电商速卖通(AliExpress)数据采集与 API 接口接入全方案
大数据·开发语言·前端·数据库·人工智能·python