【Python入门】洛谷刷题Day1

P1001

A+B Problem

s = input().split()
print(int(s[0]) + int(s[1]))

P1035

[NOIP 2002 普及组] 级数求和

k=int(input())
s=0
n=0
while s<=k:
    n+=1
    s+=1/n
print(n)

P1046

[NOIP 2005 普及组] 陶陶摘苹果

apple_heights=list(map(int,input().split()))
taotao_height=int(input())
x=0
for height in apple_heights:
    if height<=taotao_height+30:
        x+=1    
print(x)

P1047

[NOIP 2005 普及组] 校门外的树

l, m = map(int, input().split())
trees=[True]*(l+1)
for _ in range(m):
    u,v=map(int, input().split())
    for i in range(u,v+1):
        trees[i]=False
remain_trees=0
for i in range(0,l+1):
    if trees[i]==True:
        remain_trees+=1
print(remain_trees)
    

P1085

[NOIP 2004 普及组] 不高兴的津津

day_hours = []
x = 0
# 循环 7 天,读取每天的学习时间
while x < 7:
    a, b = map(int, input().split())
    # 将每天的学习总时间添加到列表中
    day_hours.append(a + b)
    x += 1

# 初始化最大学习时间和对应的天数
max_day = day_hours[0]
max_index = 0
i = 0
# 遍历列表,找出最大学习时间和对应的天数
while i < 7:
    if day_hours[i] > max_day:
        max_day = day_hours[i]
        max_index = i
    i += 1

# 如果最大学习时间大于 8 小时,输出对应的天数(从 1 开始)
if max_day > 8:
    print(max_index + 1)
else:
    print(0)   

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值