当前位置:网站首页>[punch in - Blue Bridge Cup] day 5 --- lower() small
[punch in - Blue Bridge Cup] day 5 --- lower() small
2022-06-30 03:36:00 【M4chael1】
subject 1: Based on practice Time shift

Their thinking
Remainder , to be divisible by
Code
t = int(input())
print(t // 3600, end=':')
t = t % 3600
print(t // 60, end=':')
t = t % 60
print(t)
subject 2: Based on practice String comparison

Their thinking
if Judge
It usesstr.lower()Change the string to lowercase
Code
def contrast(str1, str2):
if len(str1) != len(str2):
return 1
elif str1 == str2:
return 2
elif str1.lower() == str2.lower():
return 3
elif str1.lower()!=str2.lower() and len(str1) == len(str2):
return 4
str1 = input()
str2 = input()
print(contrast(str1, str2))
subject 3: Based on practice Decomposing prime factor

Their thinking
forloop + recursive
Code
result = {
}
def decomposition(n):
res = ''
for i in range(2, n+1):
if n % i == 0:
res += str(i)
n = n // i
if n == 1:
return res
elif n in result.keys():
res += '*'
res += result[n]
return res
else:
res += '*'
res += decomposition(n)
return res
a, b = map(int, input().split())
for i in range(a, b+1):
result[i] = decomposition(i)
for k, v in result.items():
s = str(k) + '=' + str(v)
print(s)
subject 4: Based on practice Matrix multiplication

Their thinking
Matrix multiplication , List generator
Code
N, M = map(int, input().split())
rect = [list(map(int,input().split())) for i in range(N)] # List generator
rect_ans = [[0 for _ in range(N)] for _ in range(N)]
if M > 0:
rect_tmp = rect
# Calculate matrix power
for _ in range(M-1):
for i in range(N):
for j in range(N):
for k in range(N):
rect_ans[i][j] += rect_tmp[i][k] * rect[k][j]
rect_tmp = rect_ans
else:
for i in range(N):
rect_ans[i][i] = 1
# Output
for i in range(N):
for j in range(N):
print(rect_ans[i][j], end=' ')
print()
边栏推荐
- Global and Chinese market of medical mass notification system 2022-2028: Research Report on technology, participants, trends, market size and share
- [QT] QMap使用详解
- laravel9本地安装
- Personal PC installation software
- 1151_ Makefile learning_ Static matching pattern rules in makefile
- Dripping backward (II)
- Mathematical solution of Joseph Ring
- Redis中的Hash设计和节省内存数据结构设计
- Simple custom MVC optimization
- Some common functions and precautions
猜你喜欢

Tidb 6.0: rendre les GRT plus efficaces 丨 tidb Book Rush

Is the largest layoff and salary cut on the internet coming?

An article to get you started VIM
![[practical skills] how to write agile development documents](/img/38/4bab396891ce3cc42595ae8cfd45ce.png)
[practical skills] how to write agile development documents

Number of students from junior college to Senior College (4)

X书6.97版本shield-unidbg调用方式

Selenium environment installation, 8 elements positioning --01

【笔记】2022.5.27 通过pycharm操作MySQL

OP diode limit swing

图的邻接矩阵存储 C语言实现BFS
随机推荐
C#【高级篇】 C# 泛型(Generic)【需进一步补充:泛型接口、泛型事件的实例】
共124篇!墨天轮“高可用架构”干货文档分享(含Oracle、MySQL、PG)
C#【高级篇】 C# 接口(Interface)
Use common fileUpload to upload files
AppData文件夹下Local,Locallow和Roaming
QT中foreach的使用
[QT] QMap使用详解
X书6.97版本shield-unidbg调用方式
Huawei interview question: tall and short people queue up
What are outer chain and inner chain?
11: I came out at 11:04 after the interview. What I asked was really too
Litjson parses the generated JSON file and reads the dictionary in the JSON file
C # [advanced chapter] C # anonymous method [lambda expression to be supplemented...]
【常见问题】页面跨域和接口跨域
如果辨别我现在交易的外盘股指期货交易平台是否正规安全?
[personal summary] learning plan
【作业】2022.5.24 MySQL 查操作
C#【高级篇】 C# 多线程
Some common functions and precautions
The 5-year Android development interview took 20 days to join Alibaba