Skip to content

Commit

Permalink
mycode1
Browse files Browse the repository at this point in the history
  • Loading branch information
superggn committed Jun 15, 2021
1 parent c0e8417 commit d0f57fa
Show file tree
Hide file tree
Showing 8 changed files with 512 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
55 changes: 55 additions & 0 deletions ct/G.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
monster 要喝水
Description
公司终于安好饮水机了,monster 迫不及待要去接水,但是他到那里才发现前面已经有n个同事了。他数了数,饮水机一共有m个接水口。所有的同事严格按照先来后到去接水(m个接水口同时工作,哪个水龙头有空人们就去哪里,如果 n \lt mn<m,那么就只有n个接水口工作)。每个人都有一个接水的时间,当一个人接完水后,另一个人马上去接,不会浪费时间。monster 着急要开会,所以他想知道什么时候才能轮到他。
Input
第一行两个整数n和m,表示 monster 前面有n个人,饮水机有m个接水口。n, m < 1100。第二行n个整数,表示每个同学的接水时间。
Output
一行,一个数,表示轮到 monster 接水的时间
"""
"""
4 2
1 1 1 1
"""
"""
3
"""

# io

water_machine_ls = [0, 0]
people_ls = [1, 1, 1, 1]
pos_cnt = len(water_machine_ls)
time_ = 0
flag = True
# flag 为空,可以进人,进人数量 > 前面人数的时候,停止计时
# 进人之后,加时间
out_cnt = len(people_ls)
people_cnt = 0
next_idx = 0
# while True:


# while next_idx < len(people_ls):
# while pos_cnt > 0:
# out_cnt -= 1
# pos_cnt -= 1
# time_ += people_ls[next_idx]
# next_idx += 1
# if pos_cnt == 0:
# flag = False









56 changes: 56 additions & 0 deletions ct/I.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""
Description
斐波那契数列(Fibonacci sequence),又称黄金分割数列、因数学家列昂纳多·斐波那契(Leonardoda Fibonacci)以兔子繁殖为例子而引入,故又称为“兔子数列”,指的是这样一个数列:1、1、2、3、5、8、13、21、34、……在数学上,斐波那契数列以如下被以递推的方法定义
F(1)=1F(1)=1
F(2)=1F(2)=1
F(n)=F(n-1)+F(n-2)
其中 n≥3,n∈N∗
在现代物理、准晶体结构、化学等领域,斐波纳契数列都有直接的应用。
请编程实现 F(n)F(n) 函数
Input
一列正整数n, 由换行符分隔开;
Output
斐波那契函数F(n)F(n)的计算结果,由换行符隔开
"""
"""
1
2
3
4
5
6
"""
"""
1
1
2
3
5
8
"""

def fib(n):
if n <= 2:
return 1
a = 1
b = 1
for _ in range(n - 2):
a, b = b, a + b
return b


while True:
str_in = input()
if not str_in:
break
num = int(str_in)
res = fib(num)
print(res)
83 changes: 83 additions & 0 deletions ct/J.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
"""
Description
在一次渗透特别行动中,由于一个特别的隧道只能传递 0-9A-Z 这 36 个字符(注意:全部大写),聪明的你决定发明 36 进制来解决数据传输问题。
在 36 进制表达方案中,0 仍然代表 0,9 也依然代表 9,A 代表 10,B 代表 11,依次类推,Z 代表 35。
与常见 10 进制书写方法类似(如:123 这个数字,1代表百位,是最大的一位),你发明的 36 进制编码也是按照最大的位放在最左边来输出的。
题目任务:给定一个 base64 字符串,将这个 base64 所编码的原始内容转换成 36 进制并输出。
提示:首先需要将 base64 字符串解码得到原始内容,然后将原始内容转换成 36 进制的最短表达。
提示2:仔细观察样例输入输出,确保弄明白编码的方式。
Input
一个字符串,确保是符合 base64 格式的字符串。
Output
编码为 36 进制的最终结果。
"""
"""
YQ==
a
eW8=
yo
cGFzc3dvcmQgaXMgQWRtaW4xMjM0NTY=
"""

"""
2P
2
97
NZJ
23 35 19
3N4I4HGY6IPFI151WM1CU9FGSRJ8QLQSL92U
"""

"""
base64 -> binary
binary -> base36
"""

import base64


def get_36_base_char(num):
if num < 10:
return str(num)
return chr(ord("A") + num - 10)


def base_convert_36(str_in_):
num_base = 36
bin_str_ls = []
for character in str_in_:
cur_bin_str = bin(ord(character)).split('b')[-1].rjust(8, '0')
bin_str_ls.append(cur_bin_str)
bin_str = "".join(bin_str_ls)
dec_num = int(bin_str, 2)
res = []
while dec_num != 0:
cur_position_num = dec_num % num_base
dec_num //= num_base
res.append(get_36_base_char(cur_position_num))
res.reverse()
return "".join(res)


str_in = input().strip()

raw_ascii = base64.b64decode(str_in.encode()).decode()

print(base_convert_36(raw_ascii))


88 changes: 88 additions & 0 deletions ct/K.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
"""
作为一家业内技术领先的公司,C 公司一直努力为企业客户提供高质量的产品和服务。
然而天有不测风云,由于某位程序员同学的一个 typo,C 公司核心产品在最新版中引入了一个 bug,于是在新版本对外发布的第二天早上,负责技术支持的 P 同学发现手机上收到了很多家客户的反(吐)馈(槽),在快速了解清楚原因之后,P 同学决定马上派出技术支持同学们到各个客户现场处理问题。由于每家客户的环境复杂程度不同,以及工作经验原因每位技术支持同学处理问题的能力也不同,P 同学冷静的分析了一下目前的状态:
一共有 N 家客户遇到了问题,第 i 家客户需要能力值达到p[i]的技术支持同学才能解决问题;
一共有 K 位技术支持同学,第 i 位技术支持同学的能力值为w[i];
由于问题比较复杂,每位技术支持同学当天只能处理一家客户的问题;
每家客户最多只能派一位技术支持同学
P 同学希望当天能处理尽可能多家客户,聪明的你能告诉他当天最多有几家客户的问题能得到处理吗?
Input
第一行输入一个整数 T,代表数据组数,对于每组数据:
第一行输入两个整数 N (1 ≤ N ≤ 10) 和 K (1 ≤ K ≤ 10),表示出问题的客户数量和技术支持同学的人数;
第二行输入输入 N 个整数,第 i 个整数表示第 i 家客户对能力值的需求;
第三行输入 K 个整数,第 i 个整数表示第 i 位技术支持同学的能力值。
Output
对于每组输入,输出一个整数 R,表示当天最多有 R 家客户的问题能得到处理。
"""
"""
2
3 3
5 7 9
6 8 10
3 5
5 7 9
3 3 5 3 3
"""
"""
3
1
"""


def ls_str_2_int(str_ls):
for idx in range(len(str_ls)):
str_ls[idx] = int(str_ls[idx])
return


def find_solution_num(num_ls_, client_ls_, staff_ls_):
client_ls_.sort()
staff_ls_.sort()
idx_c = len(client_ls_) - 1
idx_s = 0
cnt = 0
while idx_c >= 0:
# client 从右向左走
# staff 从左向右走
if staff_ls_[idx_s] >= client_ls_[idx_c]:
cnt += 1
staff_ls_[idx_s] *= -1
idx_s = 0
idx_c -= 1
else:
idx_s += 1
if idx_s >= len(staff_ls_):
idx_c -= 1
idx_s = 0
return cnt


case_num = int(input())
for _ in range(case_num):
num_ls = input().split()
client_ls = input().split()
staff_ls = input().split()
ls_str_2_int(num_ls)
ls_str_2_int(client_ls)
ls_str_2_int(staff_ls)
print(find_solution_num(num_ls, client_ls, staff_ls))




Loading

0 comments on commit d0f57fa

Please sign in to comment.