
CCF历年题解(Python)
mys_、
这个作者很懒,什么都没留下…
展开
-
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 阅读 · 0 评论 -
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 · 312 阅读 · 0 评论 -
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 · 304 阅读 · 0 评论 -
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 · 244 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 251 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 199 阅读 · 0 评论 -
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 · 629 阅读 · 0 评论 -
CCF Python题解(100分)201709-3 JSON查询
CCF题解(Python)201709-3 JSON查询# _*_ coding=utf-8 _*___author__ = 'SRF'__date__ = '2018/8/26 15:37'# r''都不会被转义import jsonn, m = map(int, input().split())str1 = ''for i in range(n): str1 += i...原创 2018-11-12 10:39:43 · 419 阅读 · 0 评论 -
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 · 235 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 410 阅读 · 2 评论 -
CCF Python题解(90分)201512-3 画图
CCF Python题解(90分)201512-3 画图m, n, q = map(int, input().split())canvas = [['.'] * m for i in range(n)]emoj = ['-', '|', '+']def fill(x, y, c): if x == m or y == n or x == -1 or y == -1: ...原创 2018-11-12 11:01:06 · 323 阅读 · 0 评论 -
CCF Python题解(100分)201604-3 路径解析
CCF Python题解(100分)201604-3 路径解析import reP = int(input())currentdir = input()for i in range(P): relpath = input() if relpath: # 空字符串 if re.match('^(/)+$', relpath): # 只由/构成 ...原创 2018-11-12 10:59:22 · 249 阅读 · 0 评论 -
CCF Python题解(100分)201703-3 Markdown
CCF Python题解(100分)201703-3 Markdownimport reraw = ""while True: try: inputStr = input() Str1 = re.sub("_(.*?)_", "&lt;em&gt;\g&lt;1&gt;&lt原创 2018-11-12 10:54:24 · 275 阅读 · 0 评论 -
CCF Python题解(60分)201604-4 游戏
CCF Python题解(60分)201604-4 游戏# 最短路径 广义优先搜索 BFS# 所以有时候需要在一些地方踱步,等过了这段时间再前行,就不能简单地限制为进入过的格不能再进入。from collections import dequevisited = [[[0 for k in range(301)] for i in range(101)] for j in range(1...原创 2018-11-12 10:48:34 · 260 阅读 · 0 评论 -
CCF Python题解(100分)201809-3 元素选择器
CCF Python题解(100分)201809-3 元素选择器n, m = map(int, input().split())textlist = []for i in range(n): text = input() level = text.count('.') // 2 tag = &quot;&quot; id = &quot;&quot; if len(text.spli原创 2018-11-12 10:43:36 · 625 阅读 · 3 评论 -
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 阅读 · 0 评论 -
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 · 248 阅读 · 0 评论 -
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 · 196 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 251 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 384 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 262 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 293 阅读 · 0 评论 -
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 · 198 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 215 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 242 阅读 · 0 评论 -
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 · 241 阅读 · 0 评论 -
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 · 212 阅读 · 0 评论