2016年刷题目录
2016年12月
201612-1 中间数
题目链接:
http://118.190.20.162/view.page?gpid=T52
代码:
n = int(input())
l = list(map(int,input().split()))
l = sorted(l)
if n%2 == 0:
mid = int(n/2) #int(n/2)-1
else:
mid = int(n/2)
min = l.index(l[mid])
max = len(l) - l.index(l[mid]) - l.count(l[mid])
if min == max:
print(l[mid])
else:
print(-1)
易错点需注意点:
201612-2 工资计算
题目链接:
http://118.190.20.162/view.page?gpid=T51
代码:
T = int(input())
a = 3500-1500*0.03+1500
b = 3500-1500*0.03-3000*0.1+4500
c = 3500-1500*0.03-3000*0.1-4500*0.2+9000
d = 3500-1500*0.03-3000*0.1-4500*0.2-(35000-9000)*0.25+35000
e = 3500-1500*0.03-3000*0.1-4500*0.2-(35000-9000)*0.25-20000*0.3+55000
f = 3500-1500*0.03-3000*0.1-4500*0.2-(35000-9000)*0.25-20000*0.3-(80000-55000)*0.35+80000
if T <= 3500:
print(T)
elif T <= a:
print(int(3500 + (T - 3500) / 0.97))
elif T <= b:
print(int(3500 + 1500 + (T - a) / 0.9))
elif T <= c:
print(int(3500 + 4500 + (T - b) / 0.8))
elif T <= d:
print(int(3500 + 9000 + (T - c) / 0.75))
elif T <= e:
print(int(3500 + 35000 + (T - d) / 0.7))
elif T <= f:
print(int(3500 + 55000 + (T - e) / 0.65))
else:
print(int(3500 + 80000 + (T - f) / 0.55))
易错点需注意点:
201612-3
题目链接:
代码:
易错点需注意点:
2016年09月
201609-1 最大波动
题目链接:
http://118.190.20.162/view.page?gpid=T47
代码:
n = int(input())
l = list(map(int,input().split()))
max = 0
for i in range(1,n):
if abs(l[i]-l[i-1])>max:
max = abs(l[i]-l[i-1])
print(max)
易错点需注意点:
201609-2 火车购票
题目链接:
http://118.190.20.162/view.page?gpid=T46
代码:
location = [[0 for i in range(5)] for j in range(20)]
tag_l = [5 for s in range(20)]
n = int(input())
q = list(map(int,input().split()))
for i in range(n):
k = -1 #记录哪一排余票够分配
res = []
for j in range(20):
if tag_l[j] >= q[i]:
k = j
break
if k != -1:#有连号
tag_l[k] -= q[i]
for j in range(len(location[k])):
if location[k][j] == 0:
location[k][j] = 1
q[i] -= 1
res.append(k*5+j+1)
if q[i] == 0:
break
else:#没有连号
for k in range(20):
for j in range(len(location[k])):
if location[k][j] == 0:
location[k][j] = 1
q[i] -= 1
res.append(k*5+j+1)
if q[i] == 0:
break
print(" ".join(map(str,res)))
易错点需注意点:别忘记处理如果没有连号的座位哦!
201609-3
题目链接:
代码:
易错点需注意点:
2016年04月
201604-1 折点计数
题目链接:
http://118.190.20.162/view.page?gpid=T42
代码:
n = int(input())
l = list(map(int,input().split()))
count = 0
for i in range(1,n-1):
if l[i-1] < l[i] and l[i] > l[i+1]:
count += 1
elif l[i-1] > l[i] and l[i] < l[i+1]:
count += 1
print(count)
201604-2 俄罗斯方块
题目链接:
代码: