第一行 总的课程数n(n<10); 第二行 相应课程的学分(两个学分间用空格隔开); 第三行 对应课程的实际得分; 此处输入的所有数字均为整数。
输出有一行,总评绩点,精确到小数点后2位小数。(printf("%.2f",GPA);)
5 4 3 4 2 3 91 88 72 69 56
2.52
while True: try: num = int(input()) credits = list(map(int,input().split())) scores = list(map(int,input().split())) grades = 0 for i in range(num): if 100 >= scores[i] >= 90: grades += 4.0*credits[i] elif scores[i] >= 85: grades += 3.7*credits[i] elif scores[i] >= 82: grades += 3.3*credits[i] elif scores[i] >= 78: grades += 3.0*credits[i] elif scores[i] >= 75: grades += 2.7*credits[i] elif scores[i] >= 72: grades += 2.3*credits[i] elif scores[i] >= 68: grades += 2.0*credits[i] elif scores[i] >= 64: grades += 1.5*credits[i] elif scores[i] >= 60: grades += 1.0*credits[i] print("%.2f"%(grades/sum(credits))) except Exception: break
a,b,c=input(),list(map(int,input().split())),list(map(int,input().split()))
total=0
for i,v in enumerate(c):
if 90<=v<=100:total+=b[i]*4
elif 85<=v<=89:total+=b[i]*3.7
elif 82<=v<=84:total+=b[i]*3.3
elif 78<=v<=81:total+=b[i]*3
elif 75<=v<=77:total+=b[i]*2.7
elif 72<=v<=74:total+=b[i]*2.3
elif 68<=v<=71:total+=b[i]*2
elif 64<=v<=67:total+=b[i]*1.5
elif 60<=v<=63:total+=b[i]*1
else:total+=b[i]*0
print("{0:.2f}".format(total/sum(b)))
from __future__ import division def transform(point): if 90 <= point <= 100: return 4 elif 85 <= point <= 89: return 3.7 elif 82 <= point <= 84: return 3.3 elif 78 <= point <= 81: return 3 elif 75 <= point <= 77: return 2.7 elif 72 <= point <= 74: return 2.3 elif 68 <= point <= 71: return 2 elif 64 <= point <= 67: return 1.5 elif 60 <= point <= 63: return 1 else: return 0 def gpa(n, score, point): pointList = map(int, point) scoreList = map(int, score) result = sum(map(lambda x:x[0] * x[1], zip(map(transform, pointList), scoreList))) / sum(scoreList) return "%.2f" % result try: while 1: print gpa(input(), raw_input().split(), raw_input().split()) except: pass