-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator.py
executable file
·70 lines (61 loc) · 1.8 KB
/
calculator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
测试:101:3500 203:5000 309:15000 207:6000
挑战:https://www.shiyanlou.com/courses/1140/labs/7269/document
"""
#!/usr/bin/env python3
import sys
def Rins():
ID_Dat = []
NA_Dat = []
try:
for ins in sys.argv[1:]:
tmp_in = ins.split(':')
ID_Dat.append(tmp_in[0])
NA_Dat.append(int(tmp_in[1]))
return ID_Dat, NA_Dat
except:
print("Parameter Error")
def Count(dat):
try:
bind = len(dat)
bins = 0
while bins < bind:
if dat[bins] <= 0:
return dat[bins]
else:
sefat = dat[bins] * 0.165
ifdat = dat[bins] - (3500 + sefat)
if ifdat < 0:
dat[bins] = dat[bins]
elif ifdat <= 1500:
dat[bins] -= ifdat * 0.03 - 0
elif ifdat <= 4500:
dat[bins] -= ifdat * 0.1 - 105
elif ifdat <= 9000:
dat[bins] -= ifdat * 0.2 - 555
elif ifdat <= 35000:
dat[bins] -= ifdat * 0.25 - 1005
elif ifdat <= 55000:
dat[bins] -= ifdat * 0.3 - 2755
elif ifdat <= 80000:
dat[bins] -= ifdat * 0.35 - 5505
else:
dat[bins] -= ifdat * 0.45 - 13505
dat[bins] -= sefat
bins += 1
return dat
except:
print("Parameter Error")
def Display(iddat, nadat):
bind = len(iddat)
bins = 0
while bins < bind:
print("{0}:{1:.2f}".format(iddat[bins], nadat[bins]))
bins += 1
if __name__ == '__main__':
try:
Indata = Rins()
Codata = Count(Indata[1])
Display(Indata[0], Codata)
except:
print("Parameter Error")