# Help me in solving SLAB problem

### My issue

i am unable to understand what is the issue with my logic over here in tax slabs question . MY response

for _ in range(int(input())):
n=int(input())
tax=0
if n>250000:
tax+=(min(500000,n)-250000)*0.05
if n>500000:
tax+=(min(n,750000)-500000)*0.1
if n>750000:
tax+=(min(n,10000000)-750000)*0.15
if n>10000000:
tax+=(min(n,1250000)-1000000)*0.2
if n>1250000:
tax+=(min(n,1500000)-1250000)*0.25
if n>1500000:
tax+=(n-1500000)*0.3

``````print(n-int(tax))
``````

### My code

``````for _ in range(int(input())):
n=int(input())
tax=0
if n>250000:
tax+=(min(500000,n)-250000)*0.05
if n>500000:
tax+=(min(n,750000)-500000)*0.1
if n>750000:
tax+=(min(n,10000000)-750000)*0.15
if n>10000000:
tax+=(min(n,1250000)-1000000)*0.2
if n>1250000:
tax+=(min(n,1500000)-1250000)*0.25
if n>1500000:
tax+=(n-1500000)*0.3

print(n-int(tax))
``````

Problem Link: SLAB Problem - CodeChef

@hkg_2424
Your logic is not fully correct.
U can refer this for correct logic .

``````T = int(input())
while T:
T -= 1
N = int(input())
if (N <= 250000):
net_total = N

elif (N > 250000 and N <= 500000):
net_total = N - ((N - 250000) * 0.05 )

elif (N > 500000 and N <= 750000):
net_total = N - ((250000 * 0.05) + (N - 500000) * 0.1)

elif (N > 750000 and N <= 1000000):
net_total = N - ((250000 * 0.05) + (250000 * 0.1) + (N - 750000) * 0.15)

elif (N > 1000000 and N <= 1250000):
net_total = N - ((250000 * 0.05) + (250000 * 0.1) + (250000 * 0.15) + (N - 1000000) * 0.2)

elif (N > 1250000 and N <= 1500000):
net_total = N - ((250000 * 0.05) + (250000 * 0.1) + (250000 * 0.15) + (250000 * 0.2) + (N - 1250000) * 0.25)

elif (N > 1500000):
net_total = N - ((250000 * 0.05) + (250000 * 0.1) + (250000 * 0.15) + (250000 * 0.2) + (250000 * 0.25) + (N - 1500000) * 0.3)

print(int(net_total))
``````