consider example

D=5,d=2,P=1,Q=2

So series is

1 1 3 3 5

so i convert it into AP like this by multiplying d in each term

2 6 10

so i am using

AP formula sn=n/2[2a+(n-1)*d] and tn=a+(n-1)*d

my Solution is:

T=int(input())

for i in range(T):

D,d,P,Q=[int(x) for x in input().split()]

n=int(D/d)

a=d*P
di=d*Q

```
sum=(n/2)*(2*a+(n-1)*di)
ex=D%d
tn=a+(n)*di
ex=ex*(tn/d)
total=sum+ex
print(int(total))
```

it passed the first test case but showing error in second

can someone explain me what i am missing