Python 2
[Python 100] Python 100
(I)1010%10201010%107.5%2040205%4060403%60100601.5%1001001%I
(Python 2.0+)
#!/usr/bin/python
# -*- coding: UTF-8 -*-
i = int(raw_input(':'))
arr = [1000000,600000,400000,200000,100000,0]
rat = [0.01,0.015,0.03,0.05,0.075,0.1]
r = 0
for idx in range(0,6):
if i>arr[idx]:
r+=(i-arr[idx])*rat[idx]
print (i-arr[idx])*rat[idx]
i=arr[idx]
print r
# -*- coding: UTF-8 -*-
i = int(raw_input(':'))
arr = [1000000,600000,400000,200000,100000,0]
rat = [0.01,0.015,0.03,0.05,0.075,0.1]
r = 0
for idx in range(0,6):
if i>arr[idx]:
r+=(i-arr[idx])*rat[idx]
print (i-arr[idx])*rat[idx]
i=arr[idx]
print r
(Python 3.0+)
#!/usr/bin/python3
i = int(input(':'))
arr = [1000000,600000,400000,200000,100000,0]
rat = [0.01,0.015,0.03,0.05,0.075,0.1]
r = 0
for idx in range(0,6):
if i>arr[idx]:
r+=(i-arr[idx])*rat[idx]
print ((i-arr[idx])*rat[idx])
i=arr[idx]
print (r)
i = int(input(':'))
arr = [1000000,600000,400000,200000,100000,0]
rat = [0.01,0.015,0.03,0.05,0.075,0.1]
r = 0
for idx in range(0,6):
if i>arr[idx]:
r+=(i-arr[idx])*rat[idx]
print ((i-arr[idx])*rat[idx])
i=arr[idx]
print (r)
:120000 1500.0 10000.0 11500.0
[Python 100] Python 100
758***[email protected]
if...elif...else
#!/usr/bin/python # -*- coding: UTF-8 -*- import sys reload(sys) sys.setdefaultencoding('utf-8') x = int(raw_input("")) if x<=100000: bonus=x*0.1 print u":",bonus,u"" elif 100001<x<=200000: bonus=10000+(x-100000)*0.075 print u":",bonus,u"" elif 200001<x<=400000: bonus=10000+7500+(x-200000)*0.05 print u":",bonus,u"" elif 400001<x<=600000: bonus=10000+7500+10000+(x-400000)*0.03 print u":",bonus,u"" elif 600001<x<=1000000: bonus=10000+7500+10000+6000+(x-600000)*0.015 print u":",bonus,u"" elif 600001<x<=1000000: bonus=10000+7500+10000+6000+6000+(x-600000)*0.01 print u":",bonus,u""758***[email protected]
Kunz
sun***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- i = int(raw_input('')) I = [1000000,600000,400000,200000,100000,0] r = [0.01,0.015,0.03,0.05,0.075,0.1] for j in range(len(I)): if i > I[j]: b = [0,0,0,0,0,0] b[j] = i -I[j] for k in range(j+1,len(I)): b[k] = I[k-1] bonus = sum(map(lambda (i1,i2): i1 * i2,zip(b,r))) break print '',bonusKunz
sun***[email protected]
27d***163.com
#!/usr/bin/python # -*- coding: UTF-8 -*- value=int(raw_input('please input profit: ')) list1=[1000000,600000,400000,200000,100000,0] list2=[0.01,0.015,0.03,0.05,0.075,0.1] list3=[400000,200000,200000,100000,100000] for i in range(6): if value >list1[i]: v1=(value-list1[i])*list2[i] print v1 list2_new=list2[i+1:6] list3_new=list3[i:5] v2=sum(map(lambda (x,y):x*y,zip(list2_new,list3_new))) print v2 print v1+v2 break27d***163.com
DCGDDD
805***[email protected]
Python
Python
#!/usr/bin/python3 Bonus = 0; BonusRateList = [[100,0.010],[60,0.015],[40,0.030],[20,0.050],[10,0.075],[0,0.100]]; Profit = 120000; Profit /= 10000; for i in range(0, len(BonusRateList)) : if (Profit > BonusRateList[i][0]) : Bonus += ((Profit - BonusRateList[i][0]) * BonusRateList[i][1]); Profit = BonusRateList[i][0]; print (Bonus * 10000);DCGDDD
805***[email protected]
-
910***[email protected]
#!/user/bin/env python # coding=utf-8 # num = int(raw_input("")) obj = {100: 0.01, 60: 0.015, 40: 0.03, 20: 0.05, 10: 0.075, 0: 0.1} keys = obj.keys() keys.sort() keys.reverse() r = 0 for key in keys: if num > key: r += (num - key) * obj.get(key) num = key print "", r, ""-
910***[email protected]
newbie2014
209***[email protected]
Python3
def get_reward(I): rewards = 0 if I <= 10: rewards = I * 0.1 elif (I > 10) and (I <= 20): rewards = (I - 10) * 0.075 + get_reward(10) elif (I > 20) and (I <= 40): rewards = (I - 20) * 0.05 + get_reward(20) elif (I > 40) and (I <= 60): rewards = (I - 40) * 0.03 + get_reward(40) elif (I > 60) and (I <= 100): rewards = (I - 60) * 0.015 + get_reward(60) else: rewards = get_reward(100) + (I - 100) * 0.01 return rewards if __name__ == '__main__': i = 120000 print(":", i) print("", get_reward(i / 10000) * 10000)newbie2014
209***[email protected]
173***[email protected]
: yield,
# a=[100,60,40,20,10,0] b=[0.01,0.015,0.03,0.05,0.075,0.1] # def f(x): for i in range(len(a)): if n>a[i]: # c=(a[j]-a[j+1] for j in range(i,len(a)-1)) break r=sum(map(lambda x,y:x*y,b[i:],[(n-a[i])]+list(c))) yield r*10000 k=int(input("1 0\n")) while k: n=int(input('():')) print(':',next(f(n)),'()') print() k=int(input("1 0\n")) print('')173***[email protected]