CCF 2018年题目题解 - Python
生活随笔
收集整理的這篇文章主要介紹了
CCF 2018年题目题解 - Python
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
2018年刷題目錄
- 2018年12月
- 201812-1 小明上學(xué)
- 題目鏈接:
- 代碼:
- 易錯點需注意點:
- 201812-2 小明放學(xué)
- 題目鏈接:
- 代碼:
- 易錯點需注意點:
- 201812-3
- 題目鏈接:
- 代碼:
- 易錯點需注意點:
- 2018年09月
- 201809-1 賣菜
- 題目鏈接:
- 代碼:
- 易錯點需注意點:
- 201809-2 買菜
- 題目鏈接:
- 代碼:
- 易錯點需注意點:
- 201809-3
- 題目鏈接:
- 代碼:
- 易錯點需注意點:
- 2018年03月
- 201803-1 跳一跳
- 題目鏈接:
- 代碼:
- 201803-2 碰撞的小球
- 題目鏈接:
- 代碼:
- 易錯點需注意點:直接模擬就好了,放手大膽的去做!
- 201803-3
- 題目鏈接:
- 代碼:
- 易錯點需注意點:
2018年12月
201812-1 小明上學(xué)
題目鏈接:
http://118.190.20.162/view.page?gpid=T80
代碼:
r,y,g = map(int,input().split()) n = int(input()) sum_t = 0 for i in range(n):c,t = map(int,input().split())if c == 0:sum_t += telif c == 1:sum_t += telif c == 2:sum_t += (t+r)else:pass print(sum_t)易錯點需注意點:
201812-2 小明放學(xué)
題目鏈接:
http://118.190.20.162/view.page?gpid=T81
代碼:
def judge(r,g,y,t):#返回當(dāng)前處于哪個燈,剩余多少秒if t<r:return r-telif t>=r and t<r+g:return 0elif t>=r+g and t<r+g+y:return r+g+y-t+rr,y,g = map(int,input().split()) n = int(input()) sum_t = 0 #記錄小明放學(xué)總時間 for i in range(n):c,spend = map(int,input().split())if c == 0:sum_t += spendelif c == 1:temp = (r-spend + sum_t)%(r+g+y)t = judge(r,g,y,temp)sum_t += telif c == 2:temp = (r+g+y-spend + sum_t)%(r+g+y)t = judge(r,g,y,temp)sum_t += telif c == 3:temp = (r+g-spend + sum_t)%(r+g+y)t = judge(r,g,y,temp)sum_t += t print(sum_t)易錯點需注意點:
注意計算黃燈的等待時間時要多加上一個紅燈,因為如果到達該路口時是黃燈,還要在等一個紅燈!
201812-3
題目鏈接:
代碼:
易錯點需注意點:
2018年09月
201809-1 賣菜
題目鏈接:
http://118.190.20.162/view.page?gpid=T79
代碼:
n = int(input()) price = list(map(int,input().split())) new_price = [0 for i in range(n)] for i in range(n):if i == 0:new_price[i] = (price[i] + price[i+1])//2elif i == n-1:new_price[i] = (price[i - 1] + price[i]) // 2else:new_price[i] = (price[i - 1] + price[i + 1]+price[i]) // 3 print(" ".join(map(str,new_price)))易錯點需注意點:
認真讀題,題目中說1)自己與相鄰店鋪價格的平均值 2)編號為1和n的店鋪只有一家相鄰的!
201809-2 買菜
題目鏈接:
http://118.190.20.162/view.page?gpid=T78
代碼:
n = int(input()) time = [0 for i in range(1000001)] for i in range(2*n):start,end = map(int,input().split())for j in range(start,end):time[j] += 1 print(time.count(2))易錯點需注意點:
201809-3
題目鏈接:
代碼:
易錯點需注意點:
2018年03月
201803-1 跳一跳
題目鏈接:
http://118.190.20.162/view.page?gpid=T73
代碼:
l = list(map(int,input().split())) score = 0 count = 0 for i in range(len(l)):if l[i] == 2:count += 1score += (count * 2)else:score += l[i]count = 0 print(score)201803-2 碰撞的小球
題目鏈接:
http://118.190.20.162/view.page?gpid=T72
代碼:
n,L,t = map(int,input().split()) location = list(map(int,input().split())) direction = [1 for i in range(n)] new_location = sorted(location) index = {} for i in range(n):index[i] = location.index(new_location[i]) for i in range(t):for j in range(n):new_location[j] += direction[j]if new_location[j] == new_location[j-1]:direction[j] = (-1)*direction[j]direction[j-1] = (-1) * direction[j-1]elif new_location[j] == 0 or new_location[j]==L:direction[j] = (-1)*direction[j] index = sorted(index.items(),key=lambda x:x[1]) for i in range(n):if i == n-1:print(new_location[index[i][0]])else:print(new_location[index[i][0]],end=' ')易錯點需注意點:直接模擬就好了,放手大膽的去做!
201803-3
題目鏈接:
代碼:
易錯點需注意點:
總結(jié)
以上是生活随笔為你收集整理的CCF 2018年题目题解 - Python的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CCF 2019年题目题解 - Pyth
- 下一篇: CCF 2017年题目题解 - Pyth