- 博客(47)
- 收藏
- 关注
原创 CCF Python题解(超时80分)201909-3 字符画
# _*_ coding=utf-8 _*___author__ = 'SRF'__date__ = '2019/11/23 10:33''''\033 转义序列的开始输出一行字符重置终端程序结束恢复默认前景 背景空格\x20换行\x0A'''defaback = [0, 0, 0]reset = "[0m"last = []s = ""prefix = "\\x1B"...
2019-11-24 16:37:40
422
原创 CCF Python题解(100分)201903-3 损坏的RAID5
# _*_ coding=utf-8 _*___author__ = 'SRF'__date__ = '2019/11/24 11:25'# hex(int(a,16)^(b,16))'''b//s 条带号g=b//(s*(n-1)) 组号 校验盘号pid=n-1-g%n要将块号映射到磁盘号和该磁盘块号'''n, s, l = map(int, input().split())...
2019-11-24 16:33:47
311
原创 字梯问题 bfs python
字梯问题给定两个单词(start, end)和一个字典,要求找出从单词start变化到end的最小序列。变化过程中出现的中间单词必须是字典中有的单词,且每次只能是变化其中的一个字母。比如start= “hit”, end= “cog”, dict = [“hot”, “dot”, “dog”, “lot”, “log”]。 那么从start变化到end经过了5步,即"hit"→"hot" →"...
2019-05-26 09:18:22
802
转载 STL基本算法
//不可变序列算法示例 #include<iostream>#include<algorithm>#include<functional>#include<vector>using
2019-02-15 22:59:30
308
转载 关联容器
//set#include<iostream>#include<iterator>#include<set>#include<utility>using namespace std;int main(){ set<double> s; pair&
2019-02-13 23:44:49
150
原创 STL 容器
分类向量vector双端队列deque列表list集合set多重集合multiset映射map多重映射multimap按容器中元素的组织方式顺序容器list vector deque关联容器按与容器相关的迭代器类型可逆容器(双向)随机访问容器 vector deque通用功能用默认构造函数构造空容器== 、 != 、<、<=、>、...
2019-02-13 20:28:30
155
原创 CCF Python题解(超时)201809-4 再卖菜
num = int(input())new = list(map(int, input().split()))old = [0 for i in range(num)]visited = [[[0 for k in range(300)] for i in range(300)] for j in range(300)]def dfs(n, x, y):if visited[n][x][...
2018-12-31 11:14:15
627
原创 CCF Python题解(100分)201312-1 出现次数最多的数
from collections import Countern = int(input())data = list(map(int, input().split()))info = Counter(data)selected = []times = info.most_common(1)[0][1]for index, item in info.items(): if it...
2018-11-16 22:31:50
303
原创 CCF Python题解(100分)201403-1 相反数
n = int(input())data = list(map(int, input().split()))positive = []negative = []for i in data: if i > 0: positive.append(i) else: negative.append(i)positive.sort()neg...
2018-11-16 22:25:33
243
原创 CCF Python题解(100分)201409-1 相邻数对
n = int(input())data = list(map(int, input().split()))data.sort()count = 0for index in range(len(data) - 1): if data[index + 1] - data[index] == 1: count += 1print(count)
2018-11-16 22:14:27
223
原创 CCF Python题解(100分)201412-1 门禁系统
# _*_ coding=utf-8 _*___author__ = 'SRF'__date__ = '2018/8/26 8:28'count = int(input())info = input().split()dict1 = {}newinfo = []for i in info: if i not in dict1.keys(): dict1[i]...
2018-11-16 22:12:30
309
原创 CCF Python题解(100分)201512-1 数位之和
n = int(input())sum = 0def f(num, sum=0): sum += num % 10 if num == 0: print(sum) else: f(num // 10, sum)f(n)
2018-11-16 22:08:08
218
原创 CCF Python题解(100分)201503-1 图像旋转
n, m = map(int, input().split())data = []for i in range(n): data.append(input().split())for j in range(m - 1, -1, -1): for i in range(n): print(data[i][j], end=" ") print()
2018-11-16 22:07:38
250
原创 CCF Python题解(100分)201509-1 数列分段
n = int(input())array = input().split()count = 1for index in range(n-1): if array[index + 1] != array[index]: count += 1print(count)
2018-11-16 22:05:51
356
原创 CCF Python题解(100分)201604-1 折点计数
n = int(input())data = list(map(int, input().split()))count = 0for i in range(1, len(data) - 1): if (data[i] - data[i - 1]) * (data[i + 1] - data[i]) < 0: count += 1print(count)
2018-11-16 22:03:03
198
原创 CCF Python题解(100分)201609-1 最大波动
n = int(input())prices = list(map(int, input().split()))dif = []for index in range(len(prices)-1): dif.append(abs(prices[index + 1] - prices[index]))print(max(dif))
2018-11-16 21:56:24
233
原创 CCF Python题解(100分)201612-1 中间数
n = int(input())data = list(map(int, input().split()))data.sort()set1 = set(data)flag = Falsefor s in set1: blist = [i for i in data if i &gt; s] slist = [i for i in data if i &lt; s] ...
2018-11-16 21:32:27
247
原创 CCF Python题解(100分)201703-1 分蛋糕
n, k = map(int, input().split())weights = list(map(int, input().split()))count = 0getw = 0for i in weights[:]: getw += i weights.remove(i) if getw >= k or len(weights) == 0: ...
2018-11-14 22:37:37
194
原创 CCF Python题解(100分)201709-1 打酱油
N = int(input())max5 = N // (5 * 10)list1 = []for i in range(max5 + 1): rest = N - 10 * 5 * i count = i * (5 + 2) max3 = rest // (10 * 3) count += max3 * (3 + 1) rest -= max3 * ...
2018-11-14 22:36:24
214
原创 CCF Python题解(100分)201712-1 最小差值
# _*_ coding=utf-8 _*___author__ = 'SRF'__date__ = '2018/8/26 10:22'# sorted 返回一个新列表# sort 在原列表上修改count = input()data = list(map(int, input().split()))data.sort()r = data[1] - data[0]for i in...
2018-11-14 22:35:02
158
原创 CCF Python题解(100分)201803-1 跳一跳
# _*_ coding=utf-8 _*___author__ = 'SRF'__date__ = '2018/8/26 9:56'# 1 没跳到中心# 2 跳到中心# 0 没跳到方块上data = input()index = 0count = 1score = 0for i in range(len(data)): if data[i] == '1': ...
2018-11-14 22:33:09
194
原创 CCF Python题解(100分)201312-2 ISBN号码
raw = input()isbn = raw.replace('-', '')list1 = list(isbn)code = list1[-1]sum = 0for index in range(9): sum += int(list1[index]) * (index + 1)realcode = str(sum % 11)if realcode == '10': ...
2018-11-14 22:31:27
240
原创 CCF Python题解(100分)201403-2 窗口
N, M = map(int, input().split())windows = []# 窗口输入时从最下层到最顶层的顺序for i in range(N): windows.insert(0, list(map(int, input().split())))oldwindows = windows[:]for j in range(M): flag = False ...
2018-11-14 22:30:34
240
原创 CCF Python题解(100分)201409-2 画图
n = int(input())data = [[1] * 101 for i in range(101)]count = 0for i in range(n): x1, y1, x2, y2 = map(int, input().split()) for i in range(x1, x2): for j in range(y1, y2): ...
2018-11-14 22:29:14
211
原创 CCF Python题解(100分)201412-2 Z字形扫描
n = int(input())nums = []for i in range(n): nums.append(list(map(int, input().split())))i = 0j = 0print(nums[0][0], end=" ")flag = "right"while True: if flag == 'right': j += 1...
2018-11-14 22:28:07
362
原创 CCF Python题解(100分)201503-2 数字排序
from collections import Counter, defaultdictn = int(input())data = list(map(int, input().split()))info = Counter(data)infolist = []realdict = defaultdict(set)for value in info.values(): for...
2018-11-14 22:24:09
220
原创 CCF Python题解(100分)201509-2 日期计算
y = int(input())d = int(input())days = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]if (y % 4 == 0 and y % 100 != 0) or y % 400 == 0: days[2] = 29count = 0for index in range(13): m...
2018-11-14 22:16:44
197
原创 CCF Python题解(100分)201512-2 消除类游戏
import copyn, m = map(int, input().split())data = []for i in range(n): data.append(input().split())newdata = copy.deepcopy(data)for row in range(n): for col in range(m - 2): if ...
2018-11-13 15:55:25
291
原创 CCF Python题解(100分)201604-2 俄罗斯方块
data = []new = []for i in range(15): data.append(list(map(int, input().split())))for i in range(4): new.append(list(map(int, input().split())))dcol = int(input())def getpoint(lindex,...
2018-11-13 15:53:20
656
原创 CCF Python题解(100分)201609-2 火车购票
n = int(input())seats = [[1] * 5 for i in range(20)]num = list(map(int, input().split()))def seat(k): if k == 1: for i in range(20): for j in range(5): if...
2018-11-13 15:51:55
249
原创 CCF Python题解(100分)201612-2 工资计算
import matht = int(input())salaryrange = [0, 1500, 4500, 9000, 35000, 55000, 80000, 100000 - 3500]taxrate = [3, 10, 20, 25, 30, 35, 45]tranges = [3500]for i in range(1, len(salaryrange)): t...
2018-11-13 15:50:15
248
原创 CCF Python题解(100分)201703-2 学生排队
n = int(input())m = int(input())queue = [i for i in range(1, n + 1)]for i in range(m): p, q = map(int, input().split()) for index in range(n): if queue[index] == p: qu...
2018-11-13 15:48:27
382
原创 CCF Python题解(100分)201709-2 公共钥匙盒
# 公共钥匙盒from collections import defaultdictn, k = map(int, input().split())timeline = defaultdict(list)for i in range(k): w, s, c = map(int, input().split()) timeline[s].append(w)#取出为正 ...
2018-11-13 15:45:43
228
原创 CCF Python题解(100分)201712-2 游戏
CCF Python题解(100分)201712-2 游戏# _*_ coding=utf-8 _*___author__ = 'SRF'__date__ = '2018/8/26 14:30'# n 上次记录到的值# import sys# sys.setrecursionlimit(1000000)n, k = map(int, input().split())list1...
2018-11-13 13:19:06
238
原创 CCF Python题解(100分)201803-2 碰撞的小球
CCF Python题解(100分)201803-2 碰撞的小球from collections import defaultdictn, L, t = map(int,input().split())positions = map(int,input().split())list1 = [1 for i in range(n)]for j in range(t): dict...
2018-11-13 13:17:02
259
原创 CCF Python题解(100分)201312-3 最大的矩形
CCF Python题解(100分)201312-3 最大的矩形n = int(input())data = list(map(int, input().split()))def square(index): count = 1 for i in range(index+1,len(data)): if data[i] >= data[index]:...
2018-11-13 13:13:52
205
原创 CCF Python题解(100分)201403-3 命令行选项
CCF Python题解(80分)201412-3 集合竞价form = input()n = int(input())def judge(str3): flag = True for k in str3: if not (k.islower() or k.isdigit() or i == '-'): flag = False ...
2018-11-13 13:02:07
338
原创 CCF Python题解(100分)201409-3 字符串匹配
CCF Python题解(100分)201409-3 字符串匹配import res = input()flag = input() # 1大小写敏感n = int(input())for i in range(n): inputstr = input() if flag == '1': # 大小写敏感 if s in inputstr: ...
2018-11-12 11:15:35
233
原创 CCF Python题解(100分)201412-3 集合竞价
CCF Python题解(100分)201412-3 集合竞价from collections import defaultdictrecords = []def zero(): return 0buy = defaultdict(zero)sell = defaultdict(zero)okdict = {}while True: try: ...
2018-11-12 11:13:02
732
原创 CCF Python题解(100分)201503-3 节日
CCF Python题解(100分)201503-3 节日a, b, c, y1, y2 = map(int, input().split())data = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]def day(y1, days=0): for i in range(1850, y1): days +...
2018-11-12 11:07:23
408
2
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人