洛谷题单-入门2-分支结构-python-下

找出出现的最早的最大值

count = 0
list_number = []
while True:
    list_number.append(list(map(int, input().split())))
    count += 1

    if count == 7:
        break


list2_number_total = []

for i1,i2 in list_number:
    list2_number_total.append(i1+i2)

target = max(list2_number_total)


index = 0
if target > 8:
    for i in list2_number_total:

        if i == target:
            print(index + 1)
            break
        else:
            index += 1
else:
    print(0)

需注意包装不能拆,且只能买同一种

target = int(input())
list_a = []
for i in range(3):
    list_a.append(list(map(int, input().split())))

count1 = target // list_a[0][0] if target % list_a[0][0]  == 0 else target // list_a[0][0] + 1
count2 = target // list_a[1][0] if target % list_a[1][0]  == 0 else target // list_a[1][0] + 1
count3 = target // list_a[2][0] if target % list_a[2][0]  == 0 else target // list_a[2][0] + 1

need1 = count1 * list_a[0][1]
need2 = count2 * list_a[1][1]
need3 = count3 * list_a[2][1]

print(min(need1, need2, need3))

没啥好说的

a, b, c = map(int, input().split())
bool = True
list = [a, b, c]
max_side = max(a, b, c)

list.remove(max_side)

if a + b <= c or a + c <= b or b + c <= a:
    print("Not triangle")
    bool = False

if bool:
    if list[0] ** 2 + list[1] ** 2 == max_side ** 2:
        print("Right triangle")
    elif list[0] ** 2 + list[1] ** 2 > max_side ** 2:
        print("Acute triangle")
    else:
        print("Obtuse triangle")

    if a == b or a == c or b == c :
        print("Isosceles triangle")

    if a == b == c:
        print("Equilateral triangle")

没什么好说的

target = int(input())


price1 = 0.4463
price2 = 0.4663
price3 = 0.5663

if target <= 150:
    print("{:.1f}".format(price1 * target))
elif target <= 400:
    print("{:.1f}".format((price1 * 150) + price2 * (target-150)))
else:
    print("{:.1f}".format((price1 * 150) + price2 * 250 + price3 * (target - 400)))

只需要管起始位置就行 

n1, n2 = map(int, input().split())

weeks = (n2-1) // 7
week_mlie = 1250

days = (n2-1) % 7


if n1 <= 5:
    if n1 + days < 6:
        print(week_mlie * weeks + 250 + days * 250 )
    elif n1 + days < 7:
        days -= 1
        print(week_mlie * weeks + 250 + days * 250 )
    else:
        days -= 2
        print(week_mlie * weeks + 250 + days * 250 )
elif n1 == 6:
    if days == 0:
        print(week_mlie * weeks + days * 250)
    else:
        days -= 1
        print(week_mlie * weeks + days * 250)
elif n1 == 7:
    if days == 6:
        days -= 1
        print(week_mlie * weeks + days * 250)
    else:
        print(week_mlie * weeks + days * 250)

因为只找正弦,所以直接剔除最长边就行

from math import *
list_number = list(map(int, input().split()))

max  = max(list_number)
list_number.remove(max)
n1 = gcd(min(list_number[0], list_number[1]), max)

print("{:}/{:}".format(min(list_number[0] // n1, list_number[1]), max // n1))

没啥好说的

list_1 = list(map(int, input().split()))
target = int(input())
count = 0

for i in list_1:
    if i <= target + 30:
        count += 1

print(count)

没啥好说的

list_1 = list(map(int, input().split()))
str_1 = input()

a =min(list_1)
list_1.remove(a)

a = str(a)

b = min(list_1)
list_1.remove(b)
b = str(b)

c = str(list_1[0])

str_2 = str_1[0] + " " + str_1[1] + " " + str_1[2]

print(str_2.replace("A",a).replace("B",b).replace("C",c))

Right写成了right,花了我几个小时找,终于全过了

str_1 = input()

target = str_1[-1]

count = 1
sum = 0
for i in str_1:
    if i == '-':
        continue
    sum += int(i) * count
    count += 1
    if count == 10:
        break

target_count = sum % 11

if target_count == 10:
    target_count = "X"
else:
    target_count = str(target_count)

if target_count != str_1[12]:
    print(str_1[:12:] + target_count)
else:
    print("Right")

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值