蓝桥杯练习4

a = int(input())
b = int(input())
t = int(input())
print((a*60+b+t)//60)
print((a*60+b+t)%60)

 

 

ans = 0
for i in range(27, 100):
    if i - 27 == int(str(i)[1] + str(i)[0]):
        ans += 1
print(ans)

 

total = 200
ans = []
for i in range(1, total):
    x_1 = i
    x_2 = 10 * x_1
    if (total - x_1 - x_2*2) % 5 == 0 and (total - x_1 - x_2*2) >= 0:
        x_5 = (total - x_1 - x_2 * 2) // 5
        ans.append(x_1 + x_2 + x_5)
print(min(ans))

 

 

import math

n = int(input())
for i in range(n):
    indx = [0, 0, 0, 0]
    string = input()
    cmd = []
    j1 = 0
    while True:
        if string[j1].isalpha():
            cmd.append(string[j1])
        else:
            for k in range(len(string), j1, -1):
                if string[j1:k].isdigit():
                    cmd.append(string[j1:k])
                    j1 = k-1
                    break
        j1 += 1
        if j1 >= len(string):
            break
    string1 = string
    digit = string1.replace('L', ' ').replace('R', ' ').split()
    x = 0
    for j in range(len(cmd)):
        if cmd[j].isdigit():
            cmd[j] = digit[x]
            x += 1
    flag = 0
    for j in range(len(cmd)):
        if cmd[j].isdigit():
            indx[flag] += int(cmd[j])
        else:
            if cmd[j] == 'L':
                flag += 1
            if cmd[j] == 'R':
                flag -= 1
    distance = [indx[0] - indx[2], indx[1] - indx[3]]
    ans = math.sqrt(distance[0] ** 2 + distance[1] ** 2)
    print('%.2f' % ans)

思路:字符串处理和数字提取最后坐标表示

n = int(input())
a, b, c = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    if i % a != 0 and i % b != 0 and i % c != 0:
        ans += 1
print(ans)

 

from datetime import *


def count_mondays(start_year, start_month, start_day, end_year, end_month, end_day):
    start_date = datetime(start_year, start_month, start_day)
    end_date = datetime(end_year, end_month, end_day)

    count = 0
    flag = start_date
    while flag <= end_date:
        if flag.weekday() == 0:
            count += 1
        flag += timedelta(days=1)

    return count


start_year = 1901
start_month = 1
start_day = 1
end_year = 2000
end_month = 12
end_day = 31

ans = count_mondays(start_year, start_month, start_day, end_year, end_month, end_day)
print(ans)

 思路:使用datetime模块进行时间处理

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值