蓝桥杯刷题--python-7

0幸运数字 - 蓝桥云课 (lanqiao.cn)

复制代码
count = 0


def add_sum(num):
    nums = []
    for i in num:
        nums.append(int(i))
    return sum(nums)


for i in range(1, 999999):
    if count < 2023:
        bin_num = bin(i)[2:]
        oct_num = oct(i)[2:]
        hex_num = hex(i)[2:]
        tm = []
        for j in hex_num:
            tm.append(int(j, 16))
        if i % add_sum(bin_num) == 0 and i % add_sum(oct_num) == 0 and i % sum(tm) == 0 and i % add_sum(str(i)) == 0:
            count += 1
    else:
        print(i - 1)
        break

0缩位求和 - 蓝桥云课 (lanqiao.cn)

import os

import sys

请在此输入您的代码

def dfs(num):

s=str(num)

nums_l = list(map(int, list(s)))

if len(nums_l)==1:

return nums_l[0]

return dfs(sum(nums_l))

n=int(input())

print(dfs(n))

0ISBN号码 - 蓝桥云课 (lanqiao.cn)

import os

import sys

请在此输入您的代码

n='0-670-82162-4'

n='0-670-82162-4'

n=input()

['0', '-', '6', '7', '0', '-', '8', '2', '1', '6', '2', '-', '4']

res=0

num=1

for i in n[:-2]:

if not i =='-':

res+=int(i)*num

num+=1

id=res % 11

if id ==10:

id='X'

if n[-1]==str(id):

print("Right")

else:

print(n[:-1]+str(id))

相关推荐
麻雀202512 小时前
一键面试prompt
面试·职场和发展·prompt
big\hero13 小时前
蓝桥杯13届省题
职场和发展·蓝桥杯
Jiezcode1 天前
LeetCode 48. 旋转图像
c++·算法·leetcode·职场和发展
Greedy Alg1 天前
LeetCode 230. 二叉搜索树中第 K 小的元素
算法·leetcode·职场和发展
熬了夜的程序员1 天前
【LeetCode】48. 旋转图像
算法·leetcode·链表·职场和发展·深度优先
Miraitowa_cheems1 天前
LeetCode算法日记 - Day 56: 全排列II、话号码的字母组合
数据结构·算法·leetcode·决策树·链表·职场和发展·深度优先
元亓亓亓2 天前
LeetCode热题100--994. 腐烂的橘子--中等
算法·leetcode·职场和发展
(●—●)橘子……2 天前
记力扣2516.每种字符至少取k个 练习理解
算法·leetcode·职场和发展
Asmalin2 天前
【代码随想录day 28】 力扣 1005. K次取反后最大化的数组和
算法·leetcode·职场和发展
种自己的花呀2 天前
leetcode 3 无重复字符的最长子串
算法·leetcode·职场和发展