# 최서영
while(1):
G,T,A,D=map(int, input().split())
if G==-1:
break
team=G*A+D
team_2=team
# 2^n꼴이 아닐 때, 더해줘서 2^n꼴을 만들어주어야 한다!
for i in range(33): **# 조건 잘못 살펴봄!**
if 2**i<team<2**(i+1):
team_2=2**(i+1)
total= (T*(T-1))//2
X= total*G+(team_2-1)
Y= team_2-team
print("%d*%d/%d+%d=%d+%d"%(G,A,T,D,X,Y))
# G*A/T+D=X+Y
# 신예지 왜 하필 18이야 근데
def two(num) : # 2의 제곱수인지 아닌지 확인하는 함수(소인수 분해)
i = 2
else_num = 0 # num을 나눠줄 2 이외의 다른 수(존재 여부만 확인하면 됨)
while num != 1 :
if num%i != 0 :
else_num += 1 # 2 이외의 다른 수를 나눠줘야 함
break
num /= i
if else_num > 0 : # 2의 제곱수가 아니면 1 return
return 1
else : # 2의 제곱수이면 0 return
return 0
while True :
sum_game = 0 # 전체 게임수
plus_team = 0 # 추가해야 하는 팀수
G, T, A, D = map(int, input().split())
if D == -1 : # 종료 조건
break
sum_game += (T*(T-1))/2*G # 리그
tnmt_cnt = G*A+D # 토너먼트에 참가하는 팀수
result = two(tnmt_cnt) # 함수 결과를 result에 저장
tmp = 1 # ##1에 쓰이는 변수, 2의 제곱수로 cnt와 비교하는 데에 쓰임
if result == 1 : # 2의 제곱수가 아니면
while True: # 가까운 2의 제곱수로 만들어주는 과정(##1)
if tmp > tnmt_cnt :
plus_team = tmp-tnmt_cnt # 차이만큼 plus_team에 저장
tnmt_cnt = tmp # 가장 가까운 2의 제곱수인 tmp를 tnmt_cnt에 저장
break
tmp *= 2
while tnmt_cnt != 1 : # 토너먼트
tnmt_cnt /= 2
sum_game += tnmt_cnt
print(f"{G}*{A}/{T}+{D}={int(sum_game)}+{plus_team}")
**# 박성열 # 나태죄 성립 # 똑똑이 수상 # 단콘 0.0001초 매진**
while 1:
G,T,A,D=map(int,input().split())
if D<0:break
n=1
while 1:
if G*A+D<=n:
Y=n-G*A-D
break
n*=2
X = T*(T-1)//2*G+D+A*G+Y-1
print("%d*%d/%d+%d=%d+%d"%(G,A,T,D,X,Y))
# 이수영 깡패
while True:
teams = 0
match = 0
add_team = 0
i = 1
G, T, A, D = map(int, input().split()) # 그룹, 팀, 토너먼트 진출, 토너먼트 직행
if G == -1:
break
match = T*(T-1)//2*G # 조별리그 매치 수 계산
teams = G*A+D # 조별리그를 거친 토너먼트 진출 팀의 수
**while i < teams: # 토너먼트 진행에 추가로 필요한 팀 계산
i *= 2
add_team = i-teams
teams += add_team
match += teams-1**
print(f"{G}*{A}/{T}+{D}={match}+{add_team}")