Problem:


水道料金

  松平さんは、普段からエコに気を付けて生活をしています。先月の水道料金が 4280 円となり、いつも目標としている 4000 円を超えてしまったので、今月は節水に努めてきました。先月と比べて水道料金はどのくらい節約できたのでしょうか。

今月の使用水量 w [m3] を入力とし、先月の水道料金である 4280 円と比較して、どのくらい水道料金を節約できたかを出力するプログラムを作成してください。

  なお、水道料金は次のように計算されます。

(水道料金) = (基本料金) + (水量による料金)

水量による料金は下表のように使用量に応じて計算されます。

     段階        水量           料金

第 1 段階料金  10 [m3] まで        基本料金 1150 円 

第 2 段階料金  10 [m3] 超過 20 [m3] まで 1 [m3] あたり 125 円 

第 3 段階料金  20 [m3] 超過 30 [m3] まで 1 [m3] あたり 140 円 

第 4 段階料金  30 [m3] 超過分       1 [m3] あたり 160 円 

例えば、使用水量 40 [m3] の場合は、
基本料金 1150 円(第 1 段階) + 10 [m3] &times; 125 円(第 2 段階) + 10 [m3] &times; 140 円(第 3 段階) + 10 [m3] &times; 160 円(第 4 段階) = 5400 円 

 となります。

Input

複数のデータセットの並びが入力として与えられます。入力の終わりは -1 ひとつの行で示されます。

各データセットとして、 今月の使用水量を表す整数 w (0 ≤ w ≤ 100) が１行に与えられます。

データセットの数は 200 を超えません。

      

Output

入力データセットごとに、先月の水道料金との差を1行に出力します。

Sample Input

29
40
0
-1

Output for the Sample Input

620
-1120
3130



Sample input:
29
40
0
-1


Sample output:
620
-1120
3130

Submission status: Wrong Answer

Solution code:
from bisect import bisect
A = [0, 125, 140, 160]
B = [1150,1150,2400,3800]
C = [0,10,20,30]
while True:
    w = input()
    if w == -1:
        break
    n =  bisect(C, w) - 1
    print B[n] + A[n] * (w - C[n]) - 4280

Submission status: Accepted

Solution code:
while(True):
    n = int(input())
    if n == -1: break
    p = 1150
    if   n < 10: print(4280-p)
    elif n < 20: p += 125*(n-10); print(4280-p)
    elif n < 30: p += 125*10; p += 140*(n-20); print(4280-p)
    else: p += 125*10; p += 140*10; p += 160*(n-30); print(4280-p)

Submission status: Accepted

Solution code:
pre = 4280
v = [0,125,140,160]
while True:
    w = int(input())
    if w == -1:break

    s= 1150

    
    amari = w

    for i in reversed(range(1,4)):
        if amari > i*10:
            spam = amari - i*10
            s += spam * v[i]
            amari = i*10

    print (pre - s)

Submission status: Accepted

Solution code:
def water_charges(w):
    progressive_rate = {
    (float('inf'),30):160,
              (30,20):140,
              (20,10):125,
              (10, 0):0}

    charge = basic_charge = 1150
    for (upper, lower), rate in progressive_rate.items():
        usage = min(w, upper) - lower
        if 0 < usage:
            charge += usage * rate
            
    return charge

import sys
f = sys.stdin

last_water_charges = 4280
while True:
    w = int(f.readline())
    if w == -1:
        break
    print(last_water_charges - water_charges(w))

Submission status: Accepted

Solution code:
def f(w):
    if w <= 10:
        return 4280 - 1150
    elif w <= 20:
        return 4280 - (1150 + f1(w - 10))
    elif w <= 30:
        return 4280 - (1150 + f1(10) + f2(w - 20))
    else:
        return 4280 - (1150 + f1(10) + f2(10) + f3(w - 30))


def f1(x):
    return x * 125


def f2(x):
    return x * 140


def f3(x):
    return x * 160


while True:
    _w = int(input())
    if _w == -1:
        break
    print(f(_w))

Submission status: Accepted

Solution code:
while True:
  n = input()
  if (n == -1):
    break
  if (n <= 10):
    print 4280 - 1150
  elif (n <= 20):
    print 4280 - (1150 + (n - 10) * 125)
  elif (n <= 30):
    print 4280 - (1150 + 1250 + (n - 20) * 140)
  else:
    print 4280 - (1150 + 1250 + 1400 + (n - 30) * 160)

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==-1:break
    w=1150
    if n>30:
        w+=(n-30)*160
        n-=n-30
    if n>20:
        w+=(n-20)*140
        n-=n-20
    if n>10:
        w+=(n-10)*125
    print(4280-w)

Submission status: Accepted

Solution code:
while 1:
    w= int(input())
    if w== -1: break
    a= 1150
    if w> 10 and w<= 20:
        a+= (w-10)*125
    elif w> 20 and w<= 30:
        a+= (w-20)*140+ 1250
    elif w> 30:
        a+= (w-30)*160+ 1400+ 1250
    print(4280-a)

Submission status: Accepted

Solution code:
# Aizu Problem 0216: Cutting Down Water Bills

import sys, math, os, fractions

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def water_bill(n):
    if n <= 10:
        return 4280 - 1150
    elif n <= 20:
        return 4280 - (1150 + (n - 10) * 125)
    elif n <= 30:
        return 4280 - (1150 + 1250 + (n - 20) * 140)
    else:
        return 4280 - (1150 + 1250 + 1400 + (n - 30) * 160)

while True:
    n = int(input())
    if n == -1:
        break
    print(water_bill(n))

Submission status: Accepted

Solution code:
# AOJ 0216 Cutting Down Water Bills
# Python3 2018.6.23 bal4u

while 1:
	w = int(input())
	if w < 0: break
	s = 1150
	if w > 10:
		if w <= 20: s+= (w-10)*125
		else: s += 1250
	if w > 20:
		if w <= 30: s += (w-20)*140
		else: s += 1400
	if w > 30: s += (w-30)*160;
	print(4280-s)

Submission status: Accepted

Solution code:
def fee(w):
  acc = 1150
  if w <= 10:
    return acc
  w -= 10
  if w <= 10:
    return acc + 125 * w
  acc += 1250
  w -= 10
  if w <= 10:
    return acc + 140 * w
  acc += 1400
  w-= 10
  return acc + 160 * w



while True:
  w = int(input())
  if w == -1:
    break
  print(4280 - fee(w))

Submission status: Accepted

Solution code:
A = {0:0, 10:125, 20:140}
C = [0,10,20]
while True:
    w = input()
    if w == -1:
        break
    print 4280 - (sum(A[c]*min(10, max(0,w-c)) for c in C) + 160*(max(0,w-30)) + 1150)

Submission status: Accepted

Solution code:
while True:
	w = int(raw_input())
	if w == -1: break
	print 3130-125*max(0,min(10,(w-10)))-140*max(0,min(10,(w-20)))-160*max(0,w-30)

Submission status: Accepted

Solution code:
while 1:
	w = int(raw_input())
	if w == -1: break
	print 3130-125*max(0,min(10,w-10))-140*max(0,min(10,w-20))-160*max(0,w-30)

Submission status: Accepted

Solution code:
while 1:
	w=input()
	if w==-1:break
	print 3130-125*max(0,min(10,w-10))-140*max(0,min(10,w-20))-160*max(0,w-30)

Submission status: Accepted

Solution code:
def fee(w):
    if w>30:
        return (w-30)*160+10*140+10*125+1150
    if w>20:
        return (w-20)*140+10*125+1150
    if w>10:
        return (w-10)*125+1150
    return 1150

prev_m=4280
while True:
    W=int(input())
    if W==-1:
        break
    print(prev_m-fee(W))
    # prev_m=fee(W)

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == -1:
        break
    fee = 1150
    if n > 30:
        fee += (n - 30) * 160 + 10 * 140 + 10 * 125
    elif n > 20:
        fee += (n - 20) * 140 + 10 * 125
    elif n > 10:
        fee += (n - 10) * 125

    print(4280-fee)

Submission status: Accepted

Solution code:
while True :
    w = int(input())
    if w == -1 :
        break
    if w < 10 :
        print(4280-1150)
    elif w < 20 :
        print(4280-(1150+(w-10)*125))
    elif w < 30 :
        print(4280-(1150+10*125+(w-20)*140))
    else :
        print(4280-(1150+10*125+10*140+(w-30)*160))

Submission status: Accepted

Solution code:
while True:
    w = int(input())
    if w == -1:
        break
    ans = 1150
    w = max(w-10,0)
    ans += min(w,10)*125
    w = max(w-10,0)
    ans += min(w,10)*140
    w = max(w-10,0)
    ans += w*160
    print(4280-ans)

Submission status: Accepted

Solution code:
while 1 :
    n=int(input())
    if n==-1:
        break
    else:
        if n<=10:
            w=1150
        elif 10<n<=20:
            w=1150+(n-10)*125
        elif 20<n<=30:
            w=2400+(n-20)*140
        else:
            w=3800+(n-30)*160
        print(4280-w)

Submission status: Accepted

Solution code:
prev = 4280
while True:
    cur = 0
    m = int(input())
    if m < 0:
        break

    if m <= 10:
        cur = 1150
    elif m <= 20:
        cur = 1150 + (m-10)*125
    elif m <= 30:
        cur = 1150 + 1250 + (m-20)* 140
    else:
        cur = 1150 + 1250 + 1400 + (m-30) * 160
    print(prev-cur)
    #prev = cur

Submission status: Accepted

Solution code:
while True:
    N=int(input())
    if N== -1:
        break
    S=1150
    if N>30:
        S=S+(N-30)*160
        N-=N-30
    if N>20:
        S=S+(N-20)*140
        N-=N-20
    if N>10:
        S=S+(N-10)*125
    print(4280-S)

Submission status: Accepted

Solution code:
while True:
    w = int(input())
    if w==-1: break
    
    if w <= 10:
        mon = 1150
    elif 10 < w <= 20:
        mon = 1150 + (w-10)*125
    elif 20 < w <= 30:
        mon = 1150 + 1250 +(w-20)*140
    else:
        mon = 1150 + 1250 + 1400 +(w-30)*160
    
    print(4280-mon)

Submission status: Accepted

Solution code:
while True:
  w = int(input())
  if w == -1:
    break
  
  if w <= 10:
    price = 1150
  elif 10 < w <= 20:
    price = 1150 + (w - 10) * 125
  elif 20 < w <= 30:
    price = 2400 + (w - 20) * 140
  else:
    price = 3800 + (w - 30) * 160
    
  print(4280 - price)

Submission status: Accepted

Solution code:
while True:
    w = int(input())
    if w == -1: break
    last = 4280
    if w <= 10:
        a = 1150
    elif w <= 20:
        a = 1150 + (w-10)*125
    elif w <= 30:
        a = 1150 + 10*125 + (w-20)*140
    else:
        a = 1150 + 10*125 + 10*140 + (w-30)*160
    print(last - a)

Submission status: Accepted

Solution code:
while 1:
    w = int(input())
    if w < 0: break
    s = 1150
    if w > 10:
        if w <= 20: s+= (w-10)*125
        else: s += 1250
    if w > 20:
        if w <= 30: s += (w-20)*140
        else: s += 1400
    if w > 30: s += (w-30)*160;
    print(4280-s)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Cutting Down Water Bills
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0216

"""
import sys


def solve(w):
    ans = 1150
    if w > 10:
        ans += 125 * min(10, (w-10))
    if w > 20:
        ans += 140 * min(10, (w-20))
    if w > 30:
        ans += 160 * (w-30)
    return 4280 - ans


def main(args):
    while True:
        w = int(input())
        if w == -1:
            break
        ans = solve(w)
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
while True:
  n=int(input())
  if n==-1:
    break
  a=4280
  b=1150
  if n<=10:
    print(a-b)
  elif 10<n<=20:
    print(a-(b+(n-10)*125))
  elif 20<n<=30:
    print(a-(b+1250+(n-20)*140))
  else:
    print(a-(b+1250+1400+(n-30)*160))

Submission status: Accepted

Solution code:
from sys import exit
# A, B, C = [int(n) for n in input().split()]

# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
# exit()
while(True):
    N = int(input())
    if N < 0:
        exit()
    elif N <= 10:
        temp = 1150
        print(-(temp-4280))
    elif 10 < N <= 20:
        temp = (N - 10) * 125 + 1150
        print(-(temp-4280))
    elif 20 < N <= 30:
        temp = (N - 20) * 140 + 10 * 125 + 1150
        print(-(temp-4280))
    else:
        temp = (N - 30) * 160 + 1400 + 10 * 125 + 1150
        print(-(temp-4280))

Submission status: Accepted

Solution code:
while 1:
    w=int(input())
    if w==-1:break
    elif w<=10:
        tm=1150
    elif w<=20:
        tm=1150+125*(w-10)
    elif w<=30:
        tm=2400+140*(w-20)
    else:
        tm=3800+160*(w-30)
    print(4280-tm)

Submission status: Accepted

Solution code:
def price(n):
  if n <= 10:
    x = 1150
  elif n <= 20:
    x = 1150 + (n - 10) * 125
  elif n <= 30:
    x = 1150 + 1250 + (n - 20) * 140
  else:
    x = 1150 + 1250 + 1400 + (n - 30) * 160
  return 4280 - x

while True:
  n = int(input())
  if n == -1: break
  print(price(n))

Submission status: Accepted

Solution code:
while 1:
    w = int(input())
    if w == -1:
        break

    if w <= 10:
        price = 1150
    elif 10 < w <= 20:
        price = 1150 + (w - 10) * 125
    elif 20 < w <= 30:
        price = 2400 + (w - 20) * 140
    else:
        price = 3800 + (w - 30) * 160

    print(4280 - price)

Submission status: Accepted

Solution code:
ans = []
while 1:
    x = int(input())
    if x == -1:
        break
    if x <= 10:
        r = 1150
    elif x <= 20:
        r = 1150 + (x - 10) * 125
    elif x <= 30:
        r = 1150 + 1250 + (x - 20) * 140
    else:
        r = 1150 + 1250 + 1400 + (x - 30) * 160
    ans.append(4280 - r)
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == -1:
        break

    ans = 0
    if n <= 10:
        ans = 1150
    elif n <= 20:
        ans = 1150 + (n - 10)*125
    elif n <= 30:
        ans = 1150 + 1250 + (n - 20)*140
    else:
        ans = 1150 + 1250 + 1400 + (n - 30)*160

    print(4280 - ans)