日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

CCF 2017年题目题解 - Python

發(fā)布時間:2025/4/5 python 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CCF 2017年题目题解 - Python 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

2017年刷題目錄

    • 2017年12月
      • 201712-1 最小差值
        • 題目鏈接:
        • 代碼:
        • 易錯點需注意點:
      • 201712-2 游戲
        • 題目鏈接:
        • 代碼:
        • 易錯點需注意點:直接模擬!
      • 201712-3
        • 題目鏈接:
        • 代碼:
        • 易錯點需注意點:
    • 2017年09月
      • 201709-1 打醬油
        • 題目鏈接:
        • 代碼:
        • 易錯點需注意點:
      • 201709-2 公共鑰匙盒
        • 題目鏈接:
        • 代碼:
        • 易錯點需注意點:
      • 201709-3
        • 題目鏈接:
        • 代碼:
        • 易錯點需注意點:
    • 2017年03月
      • 201703-1 分蛋糕
        • 題目鏈接:
        • 代碼:
      • 201703-2 學(xué)生排隊
        • 題目鏈接:
        • 代碼:
        • 易錯點需注意點:
      • 201703-3
        • 題目鏈接:
        • 代碼:
        • 易錯點需注意點:

2017年12月

201712-1 最小差值

題目鏈接:

http://118.190.20.162/view.page?gpid=T68

代碼:

n = int(input()) l = list(map(int,input().split())) l = sorted(l) min = 99999 for i in range(1,n):if abs(l[i]-l[i-1])<min:min = abs(l[i]-l[i-1]) print(min)

易錯點需注意點:

201712-2 游戲

題目鏈接:

http://118.190.20.162/view.page?gpid=T67

代碼:

n,k = map(int,input().split()) number = 0 #記錄現(xiàn)在數(shù)到幾了 tag = [1 for i in range(n)] x = 0 while sum(tag) != 1:if tag[x] != 0:number += 1if number%k==0 or str(number)[-1] == str(k):tag[x] = 0x = (x+1)%n print(tag.index(1)+1)

易錯點需注意點:直接模擬!

201712-3

題目鏈接:

代碼:

易錯點需注意點:

2017年09月

201709-1 打醬油

題目鏈接:

http://118.190.20.162/view.page?gpid=T63

代碼:

import math n = int(input()) count = 0 while n!=0:if n >= 50:c = math.floor(n/50)count += (c*7)n -= c*50elif n>=30:c = math.floor(n / 30)count += (c * 4)n -= c * 30else:c = math.floor(n / 10)count += (c*1)n -= c*10 print(count)

易錯點需注意點:

201709-2 公共鑰匙盒

題目鏈接:

http://118.190.20.162/view.page?gpid=T62

代碼:

n,k = map(int,input().split()) keys = [i for i in range(1,n+1)] time_list = [] schedule = {} #True借 False還 for i in range(k):w,s,c = map(int,input().split())if s not in time_list:time_list.append(s)if s+c not in time_list:time_list.append(s+c)if s in schedule:schedule[s].append([w,True])else:schedule[s] = [[w,True]]if s+c in schedule:schedule[s+c].append([w, False])else:schedule[s+c] = [[w, False]] time_list = sorted(time_list) for time in time_list:schedule[time] = sorted(schedule[time],key=lambda x:(x[1],x[0]))for t in schedule[time]:if t[1] == False: #還keys[keys.index(0)] = t[0]elif t[1] == True: #借keys[keys.index(t[0])] = 0 print(" ".join(map(str,keys)))

易錯點需注意點:

1)借和還的True、False設(shè)置需要注意 sorted排序時默認(rèn)將False排在前面,因此根據(jù)題目中要求的先還再借,我們要把還設(shè)置成False
2)sorted自定義排序中設(shè)置兩個關(guān)鍵字輔助排序需要用括號括上,如:sorted(list,key=lambda x:(x[0],x[1]))

201709-3

題目鏈接:

代碼:

易錯點需注意點:

2017年03月

201703-1 分蛋糕

題目鏈接:

http://118.190.20.162/view.page?gpid=T57

代碼:

n,k = map(int,input().split()) l = list(map(int,input().split())) count = 0 now_weight = 0 for i in range(n):now_weight += l[i]if now_weight < k and i == n-1: count += 1elif now_weight < k:passelse:count += 1now_weight = 0 print(count)

201703-2 學(xué)生排隊

題目鏈接:

http://118.190.20.162/view.page?gpid=T56

代碼:

n = int(input()) m = int(input()) students = [i for i in range(1,n+1)] info = [] for i in range(m):p,q = map(int,input().split())s = students.index(p)if s+q == n:students.remove(p)students.append(p)elif s+q == 0:students.remove(p) #remove值 pop位置students.insert(0,p)else:students.remove(p)students.insert(s+q,p) print(" ".join(map(str,students)))

易錯點需注意點:

注意范圍!!

201703-3

題目鏈接:

代碼:

易錯點需注意點:

總結(jié)

以上是生活随笔為你收集整理的CCF 2017年题目题解 - Python的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。