Problem:


Score : 300 points

Problem Statement

AtCoDeer the deer is seeing a quick report of election results on TV.
Two candidates are standing for the election: Takahashi and Aoki.
The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.
AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i.
It is known that each candidate had at least one vote when he checked the report for the first time.

Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time.
It can be assumed that the number of votes obtained by each candidate never decreases.

Constraints

1≦N≦1000

1≦T_i,A_i≦1000 (1≦i≦N)

T_i and A_i (1≦i≦N) are coprime.

It is guaranteed that the correct answer is at most 10^{18}.

Input

The input is given from Standard Input in the following format:

N
T_1 A_1
T_2 A_2
:
T_N A_N

Output

Print the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.

Sample Input 1

3
2 3
1 1
3 2

Sample Output 1

10

When the numbers of votes obtained by the two candidates change as 2,3 → 3,3 → 6,4, the total number of votes at the end is 10, which is the minimum possible number.

Sample Input 2

4
1 1
1 1
1 5
1 100

Sample Output 2

101

It is possible that neither candidate obtained a vote between the moment when he checked the report, and the moment when he checked it for the next time.

Sample Input 3

5
3 10
48 17
31 199
231 23
3 2

Sample Output 3

6930



Sample input:
3
2 3
1 1
3 2


Sample output:
10

Submission status: Wrong Answer

Solution code:
import math
N = int(input().strip())
grid = []
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
a = 1
b = 1
i = 0
while i < N:
  n = max(math.ceil(a/grid[i][0]),math.ceil(b/grid[i][1]))
  a = grid[i][0]*n
  b = grid[i][1]*n
  i = i+1
print(a+b)

Submission status: Wrong Answer

Solution code:
import math
N = int(input().strip())
grid = []
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
a = grid[0][0]
b = grid[0][1]
i = 1
while i < N:
  n = max(math.ceil(a/grid[i][0]),math.ceil(b/grid[i][1]))
  a = grid[i][0]*n
  b = grid[i][1]*n
  i = i+1
print(a+b)

Submission status: Wrong Answer

Solution code:
import math
N = int(input().strip())
grid = []
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
a = grid[0][0]
b = grid[0][1]
i = 1
while i < N:
  n = max(a//grid[i][0],b//grid[i][1])+1
  a = grid[i][0]*n
  b = grid[i][1]*n
  i = i+1
print(a+b)

Submission status: Wrong Answer

Solution code:
import math
N = int(input().strip())
grid = []
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
a = grid[0][0]
b = grid[0][1]
i = 1
while i < N:
  n = max(a//grid[i][0],b//grid[i][1])+1
  a = grid[i][0]*n
  b = grid[i][1]*n
  i = i+1
  print(a+b)

Submission status: Wrong Answer

Solution code:
N = int(input())

dp = [0] * N
for i in range(N):
    a, t = map(int, input().split())

    if i == 0:
        dp[0] = (a, t)
        continue


    if (a < dp[i - 1][0]) and (t < dp[i - 1][1]):
        x = max(dp[i - 1][0] // a, dp[i - 1][1] // t)
        a = a * x
        t = t * x

    j = 1
    while True:
        tmp = (a * j, t * j)
        if (dp[i - 1][0] <= tmp[0]) and (dp[i - 1][1] <= tmp[1]):
            dp[i] = (a * j, t * j)
            break
        j += 1

print(dp[N-1][0] + dp[N-1][1])

Submission status: Wrong Answer

Solution code:
N = int(input())
TA = []
for i in range(N):
    TA.append(list(map(int, input().split())))

t_real = [TA[0][0]]
a_real = [TA[0][1]]

for i in range(1,N):
    t_cand = (t_real[i-1]//TA[i][0] + bool(t_real[i-1]%TA[i][0])) * TA[i][0]
    a_cand = (a_real[i-1]//TA[i][1] + bool(a_real[i-1]%TA[i][1])) * TA[i][1]
    
    if t_cand//TA[i][0] * TA[i][1] >= TA[i-1][1]:
        t_real.append(t_cand)
        a_real.append(t_cand//TA[i][0] * TA[i][1])
        
    elif a_cand//TA[i][1] * TA[i][0] >= TA[i-1][0]:
        a_real.append(a_cand)
        t_real.append(a_cand//TA[i][1] * TA[i][0])
        
    else:
        print("error")
        
        
print(t_real[-1]+a_real[-1])

Submission status: Wrong Answer

Solution code:
from math import ceil
N=int(input())
a=1
b=1
for i in range(N):
    x,y=map(int,input().split())
    n=max(ceil(a/x),ceil(b/y))
    a,b=n*x,n*y
print(a+b)

Submission status: Wrong Answer

Solution code:
#046-C
n=int(input())
to,ao=map(int,input().split())
for i in range(n-1):
    t,a=map(int,input().split())
    s=0
    if t==a:
        to=ao=max(to,ao)
    elif t<a:
        while True:
            if (to+s)%t==0:
                to+=s
                if ao<=int(to*a/t):
                    ao=int(to*a/t)
                    break   
            s+=1
    elif a<t:
        for j in range(a):
            if (ao+s)%a==0:
                ao+=s
                if to<=int(ao*t/a):
                    to=int(ao*t/a)
                    break 
            s+=1
print(to+ao)

Submission status: Wrong Answer

Solution code:
n=int(input())
to,ao=map(int,input().split())
for i in range(n-1):
    t,a=map(int,input().split())
    if t==a:
        to=ao=max(to,ao)
    elif t<a:
        for j in range(t):
            if (to+j)%t==0:
                to+=j
                if ao<=int(to*a/t):
                    ao=int(to*a/t)
                    break
                else:
                    for k in range(a):
                        if (ao+k)%a==0:
                            ao+=k
                            to=int(ao*t/a)
                            break
                        break      
    elif a<t:
        for j in range(a):
            if (ao+j)%a==0:
                ao+=j
                if to<=int(ao*t/a):
                    to=int(ao*t/a)
                    break
                else:
                    for k in range(t):
                        if (to+k)%t==0:
                            to+=k
                            ao=int(to*a/t)
                            break
                        break 
print(to+ao)

Submission status: Wrong Answer

Solution code:
n=int(input())
to,ao=map(int,input().split())
for i in range(n-1):
    t,a=map(int,input().split())
    if t==a:
        to=ao=max(to,ao)
    elif t<a:
        for j in range(t):
            if (to+j)%t==0:
                to+=j
                if ao<=int(to*a/t):
                    ao=int(to*a/t)
                    break
                else:
                    for k in range(a):
                        if (ao+k)%a==0:
                            ao+=k
                            to=int(ao*t/a)
                            break
                    break      
    elif a<t:
        for j in range(a):
            if (ao+j)%a==0:
                ao+=j
                if to<=int(ao*t/a):
                    to=int(ao*t/a)
                    break
                else:
                    for k in range(t):
                        if (to+k)%t==0:
                            to+=k
                            ao=int(to*a/t)
                            break
                    break 
print(to+ao)

Submission status: Wrong Answer

Solution code:
n=int(input())
to,ao=map(int,input().split())
for i in range(n-1):
    t,a=map(int,input().split())
    if t==a:
        to=ao=max(to,ao)
    elif t<a:
        for j in range(t):
            if (to+j)%t==0:
                to+=j
                ao=int(to*a/t)
                break
    elif a<t:
        for j in range(a):
            if (ao+j)%a==0:
                ao+=j
                to=int(ao*t/a)
                break
print(to+ao)

Submission status: Wrong Answer

Solution code:
from math import ceil
n = int(input())
ta = [list(map(int, input().split())) for _ in range(n)]

nt, na = 1, 1
for i in range(n):
    r = max([ceil(nt/ta[i][0]), ceil(na/ta[i][1])])
    nt = r*ta[i][0]
    na = r*ta[i][1]
    # print(nt, na)

print(nt+na)

Submission status: Wrong Answer

Solution code:
from math import ceil
n = int(input())
ta = [list(map(int, input().split())) for _ in range(n)]

nt, na = ta[0]
for i in range(1, n):
    
    r = max([ceil(nt/ta[i][0]), ceil(na/ta[i][1])])
    nt = r*ta[i][0]
    na = r*ta[i][1]
    # print(nt, na)

print(nt+na)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
ta = []
for i in range(n):
    ta.append([int(i) for i in input().split()])

for i in range(1, n):
    if ta[i-1][0] > ta[i][0] or ta[i-1][1] > ta[i][1]:
        multi = max(
            math.ceil(ta[i-1][0] / ta[i][0]),
            math.ceil(ta[i-1][1] / ta[i][1])
        )
        ta[i][0] *= multi
        ta[i][1] *= multi

print(ta[-1][0] + ta[-1][1])

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
rates = [list(map(int, input().split(' '))) for _ in range(N)]
candT = 1
candA = 1
for T, A in rates:
    n = max(math.ceil(candT/T), math.ceil(candA/A))
    candA = n * A
    candT = n * T

print(candT + candA)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
rates = [list(map(int, input().split(' '))) for _ in range(N)]
candT = 1
candA = 1
for T, A in rates:
    if T * candA == A * candT:
        continue
    else:
        n = max(math.ceil(candT/T), math.ceil(candA/A))
        candA = n * A
        candT = n * T

print(candT + candA)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
rates = [list(map(int, input().split(' '))) for _ in range(N)]
candT = rates[0][0]
candA = rates[0][1]
for T, A in rates:
    if T * candA == A * candT:
        continue
    else:
        n = max(math.ceil(candT/T), math.ceil(candA/A))
        candA = n * A
        candT = n * T

print(candT + candA)

Submission status: Wrong Answer

Solution code:
N =int(input())

T1=[]
T2=[]

for i in range(N):
  s=input().split()
  n=1
  if i!=0:
     while(True):
      if T1[i-1]+T2[i-1] > n*int(s[0])+n*int(s[1]):
         n+=1
      else:
         break
  T1.append(n*int(s[0]))
  T2.append(n*int(s[1]))

print(T1[N-1]+T2[N-1])

Submission status: Wrong Answer

Solution code:
from math import ceil
N = int(input())
A, B = 1, 1
for i in range(N):
    x, y = map(int, input().split())
    n = max(ceil(A/x), ceil(B/y))
    while A > n * x or B > n * y:
        n += 1
    A, B = n*x, n*y
print(A+B)

Submission status: Wrong Answer

Solution code:
from math import ceil
N = int(input())
A, B = 1, 1
for i in range(N):
    x, y = map(int, input().split())
    n = max(ceil(A/x), ceil(B/y))
    if A > n * x or B > n * y:
        n += 1
    A, B = n*x, n*y
print(A+B)

Submission status: Wrong Answer

Solution code:
from math import ceil
N = int(input())
A, B = [1, 1]
for i in range(N):
    x, y = map(int, input().split())
    n = max(ceil(A/x), ceil(B/y))
    A, B = n*x, n*y
print(A+B)

Submission status: Wrong Answer

Solution code:
from math import ceil
N = int(input())
c, d = [1, 1]
for i in range(N):
    a, b = map(int, input().split())
    k = max(ceil(c/a), ceil(d/b))
    c, d = k*a, k*b
print(c+d)

Submission status: Wrong Answer

Solution code:
from math import ceil
N = int(input())
c, d = [0, 0]
for i in range(N):
    a, b = map(int, input().split())
    if a >= c and b >= d: c, d = a, b
    else:
        k = max(ceil(c/a), ceil(d/b))
        c, d = k*a, k*b
print(c+d)

Submission status: Wrong Answer

Solution code:
def m():
    n = int(input())
    nowt, nowa = map(int, input().split())
    for _ in range(n-1):
        t, a = map(int, input().split())
        if t == a:
            nowt = max(nowt, nowa)
            nowa = max(nowt, nowa)
        elif t > a:
            if nowa < a:
                nowa = a
                nowt = int(nowa * (t / a))
                continue

            if nowt > nowa:
                if nowt < t:
                    nowt = t
                    nowa = int(nowt * (a / t))
                    continue

                nowa = int((a / t) * nowt)
                continue

            for i in range(nowa):
                if nowa < i * a:
                    nowa = i*a
                    break
            nowt = int(nowa * (t / a))
        else:
            if nowt < t:
                nowt = t
                nowa = int(nowt * (a / t))
                continue

            if nowa > nowt:
                if nowa < a:
                    nowa = a
                    nowt = int(nowa * (t / a))
                    continue
                nowt = int((t / a) * nowa)
                continue

            for j in range(nowt):
                if nowt < j * t:
                    nowt = j * t
                    break
            nowa = int(nowt * (a / t))
    return nowa + nowt

print(m())

Submission status: Wrong Answer

Solution code:
from math import ceil
N = int(input())
c, d = [0, 0]
for i in range(N):
    a, b = map(int, input().split())
    if a >= c and b >= d: c, d = a, b
    else:
        k = ceil(max(c/a, d/b))
        c, d = k*a, k*b
print(c+d)

Submission status: Wrong Answer

Solution code:
def m():
    n = int(input())
    tt, aa = map(int, input().split())
    for _ in range(n-1):
        t, a = map(int, input().split())
        if t == a:
            tt = max(tt, aa)
            aa = max(tt, aa)
        elif t > a:
            aa += aa % a
            tt = int(aa * (t / a))
        else:
            tt += tt % t
            aa = int(tt * (a / t))
    return aa + tt

print(m())

Submission status: Wrong Answer

Solution code:
import math
N = int(input())

t=1
a=1
for i in range(N):
    T , A = [int(i) for i in input().split(' ')]
 #   print(T,A)
    n1 = math.ceil(t / T)
    n2 = math.ceil(a / A)
    n = max(n1,n2)
    #while T*n <= t and A*n <= a:
     #   n += 1

    t = T*n
    a = A*n
  #  print(t,a)

print(t+a)

Submission status: Wrong Answer

Solution code:
N = int(input())
t = []
a = []
for i in range(0,N):
	tokuhyousuu = list(map(int,input().split()))
	t.append(tokuhyousuu[0])
	a.append(tokuhyousuu[1])

T = 1
A = 1

for j in range(0,N):
	if(T<=t[j] and A<=a[j]):
		T = t[j]
		A = a[j]

	elif(T>t[j] and A>a[j]):
		if(T%t[j] == 0):
			r_1 = int(T/t[j])
		else:
			r_1 = int(T/t[j])+1

		if(A%a[j] == 0):
			r_2 = int(A/a[j])
		else:
			r_2 = int(A/a[j])+1

		r = max(r_1,r_2)

		T = t[j]*r
		A = a[j]*r


	elif(T>t[j]):
		if(T%t[j]==0):
			r = int(T/t[j])
		else:
			r = int(T/t[j])+1
		
		T = t[j]*r
		A = a[j]*r

	elif(A>a[j]):
		if(A%a[j] == 0):
			r = int(A/a[j])
		else:
			r = int(A/a[j])+1			
		T = t[j]*r
		A = a[j]*r

print(T+A)

Submission status: Wrong Answer

Solution code:
N = int(input())
t = []
a = []
for i in range(0,N):
	tokuhyousuu = list(map(int,input().split()))
	t.append(tokuhyousuu[0])
	a.append(tokuhyousuu[1])

T = 1
A = 1

for j in range(0,N):
	if(T<=t[j] and A<=a[j]):
		T = t[j]
		A = a[j]

	elif(T>t[j] and A>a[j]):
		if(T%t[j] == 0):
			r_1 = int(T/t[j])
		else:
			r_1 = int(T/t[j])+1

		if(A%a[j] == 0):
			r_2 = int(A/a[j])
		else:
			r_2 = int(A/a[j])+1

		T = t[j]*(max(r_1,r_2))
		A = a[j]*(max(r_1,r_2))


	elif(T>t[j]):
		if(T%t[j]==0):
			r = int(T/t[j])
		else:
			r = int(T/t[j])+1
		
		T = t[j]*r
		A = a[j]*r

	elif(A>a[j]):
		if(A%a[j] == 0):
			r = int(A/a[j])
		else:
			r = int(A/a[j])+1			
		T = t[j]*r
		A = a[j]*r

print(T+A)

Submission status: Wrong Answer

Solution code:
N = int(input())
t = []
a = []
for i in range(0,N):
	tokuhyousuu = list(map(int,input().split()))
	t.append(tokuhyousuu[0])
	a.append(tokuhyousuu[1])

T = t[0]
A = a[0]

for j in range(0,N):
	if(T<=t[j] and A<=a[j]):
		T = t[j]
		A = a[j]

	elif(T>t[j] and A>a[j]):
		if(T%t[j] == 0):
			r_1 = int(T/t[j])
		else:
			r_1 = int(T/t[j])+1

		if(A%a[j] == 0):
			r_2 = int(A/a[j])
		else:
			r_2 = int(A/a[j])+1

		T = t[j]*(max(r_1,r_2))
		A = a[j]*(max(r_1,r_2))


	elif(T>t[j]):
		if(T%t[j]==0):
			r = int(T/t[j])
		else:
			r = int(T/t[j])+1
		
		T = t[j]*r
		A = a[j]*r

	elif(A>a[j]):
		if(A%a[j] == 0):
			r = int(A/a[j])
		else:
			r = int(A/a[j])+1			
		T = t[j]*r
		A = a[j]*r

print(T+A)

Submission status: Wrong Answer

Solution code:
N = int(input())
t = []
a = []
for i in range(0,N):
	tokuhyousuu = list(map(int,input().split()))
	t.append(tokuhyousuu[0])
	a.append(tokuhyousuu[1])

T = t[0]
A = a[0]

for j in range(0,N):
	if(T<=t[j] and A<=a[j]):
		T = t[j]
		A = a[j]

	elif(T>t[j] and A>a[j]):
		if(T%t[j] == 0):
			r_1 = int(T/t[j])
			r_2 = int(A/a[j])
		else:
			r_1 = int(T/t[j])+1
			r_2 = int(A/a[j])+1

		T = t[j]*(max(r_1,r_2))
		A = a[j]*(max(r_1,r_2))


	elif(T>t[j]):
		if(T%t[j]==0):
			r = int(T/t[j])
		else:
			r = int(T/t[j])+1
		
		T = t[j]*r
		A = a[j]*r

	elif(A>a[j]):
		if(A%a[j] == 0):
			r = int(A/a[j])
		else:
			r = int(A/a[j])+1			
		T = t[j]*r
		A = a[j]*r

print(T+A)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())

t = 1
a = 1
for i in range(N):
  T, A = list(map(int, input().split()))

  b = max(math.ceil(1.0 * t / T), math.ceil(1.0 * a / A))
  t = T * int(b)
  a = A * int(b)

print(t + a)

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
x=[1,1]
for i in range(n):
  a0,b0=x
  a ,b =[int(i) for i in input().split()]
  m=math.ceil(max(a0/a,b0/b))
  x=[m*a,m*b]
  
print(int(sum(x)))

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
x=[1,1]
for i in range(n):
  a0,b0=x
  a ,b =[int(i) for i in input().split()]
  m=max(math.ceil(a0/a),math.ceil(b0/b))
  x=[m*a,m*b]
  
print(int(sum(x)))

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
x=[1,1]
for i in range(n):
  a0,b0=x
  a ,b =[int(i) for i in input().split()]
  ac=math.ceil(a0/a)*a
  bc=math.ceil(b0/b)*b
  if (ac/a)*b >=bc and (bc/b)*a>=ac:
     x=[min(ac,(bc/b)*a), min(bc,(ac/a)*b)]
  elif (ac/a)*b >=bc:
    x=[ac,(ac/a)*b]
  else:
    x=[(bc/b)*a,bc]
    
print(int(sum(x)))

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
x=[1,1]
for i in range(n):
  a0,b0=x
  a ,b =[int(i) for i in input().split()]
  ac=math.ceil(a0/a)*a
  bc=math.ceil(b0/b)*b
  if (ac/a)*b >=bc:
    x=[ac,(ac/a)*b]
  else:
    x=[(bc/b)*a,bc]

print(int(sum(x)))

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
x=[1,1]
for i in range(n):
  a0,b0=x
  a ,b =[int(i) for i in input().split()]
  ac=math.ceil(a0/a)*a
  bc=math.ceil(b0/b)*b
  if ac>=bc:
    x=[ac,(ac/a)*b]
  else:
    x=[(bc/b)*a,bc]
  
print(int(sum(x)))

Submission status: Wrong Answer

Solution code:
from math import ceil
n = int(input())

t = 1
a = 1

for i in range(n):
    ti, ai = map(int, input().split())
    si = ceil(max(t/ti, a/ai))
    t = ti*si
    a = ai*si

print(a+t)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
T, A = map(int, raw_input().split())
oldratio = [T, A]

for i in range(1, N):
	ratio = map(int, raw_input().split())
	if oldratio != ratio:
		part = (T + A) / (ratio[0]+ratio[1]) + 1
		T = part * ratio[0]
		A = part * ratio[1]
		oldratio = [ratio[0], ratio[1]]

print T + A

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
t1 , a1 = map(int,input().split())
tt = t1
aa = a1
for i in range(n-1):
    t, a = map(int,input().split())
    n = ((max((tt//t),(aa//a))))
    tt = t * n
    aa = a * n
print(tt + aa)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
t1 , a1 = map(int,input().split())
tt = t1
aa = a1
for i in range(n-1):
    t, a = map(int,input().split())
    n = m.ceil((max((tt/t),(aa/a))))
    tt = t * n
    aa = a * n
print(tt + aa)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
t1 , a1 = map(int,input().split())
tt = t1
aa = a1
vote = tt + aa
for i in range(n-1):
    t, a = map(int,input().split())
    n = m.ceil((max((tt/t),(aa/a))))
    tt = t * n
    aa = a * n
    vote = tt + aa
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
tt , aa = map(int,input().split())
vote = tt + aa
for i in range(n-1):
    t, a = map(int,input().split())
    n = m.floor((max((tt/t),(aa/a))))
    tt = t * n
    aa = a * n
    vote = tt + aa
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
tt , aa = map(int,input().split())
vote = tt + aa
for i in range(n-1):
    t, a = map(int,input().split())
    n = m.ceil((max((tt/t),(aa/a))))
    tt = t * n
    aa = a * n
    vote = tt + aa
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
tt , aa = map(int,input().split())
vote = tt + aa
for i in range(n-1):
    t, a = map(int,input().split())
    n = (max(m.ceil(tt/t),m.ceil(aa/a)))
    tt = t * n
    aa = a * n
    vote = tt + aa
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
tt , aa = map(int,input().split())
vote = tt + aa
for i in range(n-1):
    t, a = map(int,input().split())
    n = (max(m.floor(tt/t),m.floor(aa/a)))
    tt = t * n
    aa = a * n
    vote = tt + aa
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
tt , aa = map(int,input().split())
vote = tt + aa
for i in range(n-1):
    t, a = map(int,input().split())
    n = (max(m.floor(tt/t),m.floor(aa/a)))
    tt = t * n
    aa = a * n
    vote = vote * n
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
tt , aa = 1,1
vote = tt + aa
for i in range(n):
    t, a = map(int,input().split())
    n = (max(m.floor(tt/t),m.floor(aa/a)))
    tt = t * n
    aa = a * n
    vote = vote * n
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
tt , aa = 1,1
vote = tt + aa
for i in range(n):
    t, a = map(int,input().split())
    n = (max(m.floor(tt//t),m.floor(aa//a)))
    tt = t * n
    aa = a * n
    vote = vote * n
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
tt , aa = 1,1
vote = tt + aa
for i in range(n):
    t, a = map(int,input().split())
    n = (max(tt//t,aa//a))
    tt = t * n
    aa = a * n
    vote = vote * n
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
tt , aa = 1,1
vote = tt + aa
for i in range(n):
    t, a = map(int,input().split())
    n = m.ceil(max(tt/t,aa/a))
    tt = t * n
    aa = a * n
    vote = vote * n
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
tt , aa = map(int,input().split())
vote = tt + aa
for i in range(n-1):
    t, a = map(int,input().split())
    n = m.ceil(max(tt/t,aa/a))
    tt = t * n
    aa = a * n
    vote = vote * n
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
tt , aa = map(int,input().split())
vote = tt + aa
for i in range(n-1):
    t, a = map(int,input().split())
    n = max(m.ceil(tt/t),m.ceil(aa/a))
    tt = t * n
    aa = a * n
    vote = vote * n
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
tt , aa = map(int,input().split())
vote = tt + aa
for i in range(n-1):
    t, a = map(int,input().split())
    n = max(m.ceil(tt/t),m.ceil(aa/a))
    tt = t
    aa = a
    vote = vote * n
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math as m
tt , aa = map(int,input().split())
vote = tt + aa
for i in range(n-1):
    t, a = map(int,input().split())
    n = max(m.ceil(tt/t),m.ceil(aa/a))
    vote = vote * n
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
vote = 0
tt = 0
aa = 0
for i in range(n):
    t, a = map(int,input().split())
    if (tt < t and aa == a) or (tt == t and aa < a) or (tt< t and aa <a):
        tt = t
        aa = a
        vote = t + a
    else:
        count = 1
        s = t + a
        while vote > s:
            count = count + 1
            s = s * count
            
        vote = s
        tt = count * t
        ss = count * a
            
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
vote = 0

for i in range(n):
    t, a = map(int,input().split())
    s = t + a
    if vote < s:
        vote = s
    else:
        count = 1
        while vote > s:
            count = count + 1
            s = s * count
            
        vote = s
            
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
vote = 0

for i in range(n):
    t, a = map(int,input().split())
    s = t + a
    if vote < s:
        vote = s
    else:
        count = 1
        while vote > s:
            s = s * count
            count += 1
        vote = s
            
print(vote)

Submission status: Wrong Answer

Solution code:
n = int(input())
vote = 0

for i in range(n):
    t, a = map(int,input().split())
    s = t + a
    if vote < s:
        vote = s
    else:
        count = 1
        while vote > s:
            s = s * count
            count += 1
            
print(vote)

Submission status: Wrong Answer

Solution code:
N = int(input())
V = [list(map(int,input().split())) for k in range(N)]
T = 1
A = 1
t = 0
for k in V:
    while k[0]*t < T or k[1]*t < A:
        t += 1
    T = k[0]*t
    A = k[1]*t

print(T+A)

Submission status: Wrong Answer

Solution code:
from math import ceil
N = int(input())
V = [list(map(int,input().split())) for k in range(N)]
T = 1
A = 1

for k in V:
    x = max(ceil(T/k[0]),ceil(A/k[1]))
    T = k[0]*x
    A = k[1]*x

print(T+A)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
x,y=1,1
for i in range(N):
    a,b=map(int,input().split())
    s=max(math.ceil(x/a),math.ceil(y/b))
    x=s*a
    y=s*b
print(x+y)

Submission status: Wrong Answer

Solution code:
n = int(input())
kouho = 0
for i in range(n):
    t,a = map(int,input().split())
    s = t + a
    if kouho <= s:
        kouho = s
    else:
        j = 1
        while kouho > s:
            s = s * j
            j = j + 1
        kouho = s
print(s)

Submission status: Wrong Answer

Solution code:
N=int(input())
a,b=map(int,input().split())
for i in range(N-1):
    x,y=map(int,input().split())
    if x>=a:
        a=x
    elif x<a and a%x!=0:
        n=a//x+1
        a=n*x
        b=n*y
    else:
        b=max(b,a*y//x)
    if y>=b:
        b=y
    elif y<b and b%y!=0:
        m=b//y+1
        b=m*y
        a=m*x
    else:
        a=max(a,b*x//y)
print(a+b)

Submission status: Wrong Answer

Solution code:
from math import ceil
n = int(input())
a, b = 1, 1

for i in range(n):
  x, y = map(int, input().split())
  m = max(ceil(a/x), ceil(b/y))
  a = x*m
  b = y*m

print(a+b)

Submission status: Wrong Answer

Solution code:
n=int(input())
t=[tuple(map(int,input().split()))for i in range(n)]
import math
dp=[0]*n
dp[0]=1
if 2<=n:
    for i in range(1,n):
        dp[i]=math.ceil(max(t[i-1][0]/t[i][0],t[i-1][1]/t[i][1])*dp[i-1])
    x=dp[-1]
    print(x*t[n-1][0]+x*t[n-1][1])
else:
    print(t[0][0]+t[0][1])

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
nums = [list(map(int,input().split())) for _ in range(n)]
a, b = 1, 1
p = 1
for i in range(n):
    x, y = nums[i][0], nums[i][1]
    p = max(math.ceil(a/x), math.ceil(b/y))
    a, b = p * x, p * y
        
print(a + b)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
n = int(input())
nums = [list(map(int,input().split())) for _ in range(n)]
a, b = nums[0][0], nums[0][1]
for i in range(1, n):
    if a / nums[i][0] != b / nums[i][1]:
        p, q = nums[i][0], nums[i][1]
        while p < a:
            p += nums[i][0]
        while q < b:
            q += nums[i][1]
        a, b = p, q
        
print(a + b)

Submission status: Wrong Answer

Solution code:
n=int(input())
t=[tuple(map(int,input().split()))for i in range(n)]
import math
dp=[0]*n
dp[0]=1
for i in range(1,n):
    dp[i]=round(max(t[i-1][0]/t[i][0],t[i-1][1]/t[i][1])*dp[i-1])
x=dp[-1]
print(x*t[n-1][0]+x*t[n-1][1])

Submission status: Wrong Answer

Solution code:
n=int(input())
t=[tuple(map(int,input().split()))for i in range(n)]
import math
dp=[0]*n
dp[0]=1
for i in range(1,n):
    dp[i]=round(max(t[i-1][0]/t[i][0],t[i-1][1]/t[i][1])*dp[i-1])
x=dp[-1]
print(dp)
print(x*t[n-1][0]+x*t[n-1][1])

Submission status: Wrong Answer

Solution code:
n=int(input())
t=[tuple(map(int,input().split()))for i in range(n)]
import math
dp=[0]*n
dp[0]=1
for i in range(1,n):
    dp[i]=math.ceil(max(t[i-1][0]/t[i][0],t[i-1][1]/t[i][1])*dp[i-1])
x=dp[-1]
print(x*t[n-1][0]+x*t[n-1][1])

Submission status: Wrong Answer

Solution code:
n=int(input())
t=[tuple(map(int,input().split()))for i in range(n)]
import math
dp=[0]*n
dp[0]=1
for i in range(1,n):
    dp[i]=math.ceil(max(t[i-1][0]/t[i][0],t[i-1][1]/t[i][1])*dp[i-1])
x=dp[-1]
print(x*(t[n-1][0]+t[n-1][1]))

Submission status: Wrong Answer

Solution code:
from math import ceil
N = int(input())
T,A = 1,1
for i in range(N):
    Ti,Ai = map(int,input().split())
    r = max(ceil(T/Ti),ceil(A/Ai))
    T,A = Ti*r,Ai*r
print(T+A)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
tal = [[int(i) for i in input().split()] for i in range(n)]
t,a = 1,1 
for i in range(n):
    m = max(math.ceil(t/tal[i][0]),math.ceil(a/tal[i][1]))
    if t>t*m or a>a*m:
        m += 1
    t = m*tal[i][0]
    a = m*tal[i][1]
print(a+t)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
tal = [[int(i) for i in input().split()] for i in range(n)]
t,a = 1,1 
for i in range(n):
    m = max(math.ceil(t/tal[i][0]),math.ceil(a/tal[i][1]))
    t = m*tal[i][0]
    a = m*tal[i][1]
print(a+t)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
tal = [[int(i) for i in input().split()] for i in range(n)]
t,a = 1,1 
for i in range(n):
    quote = max(math.ceil(a/tal[i][1]),math.ceil(t/tal[i][0]))
    t = quote*tal[i][0]
    a = quote*tal[i][1]

print(a+t)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
tal = [[int(i) for i in input().split()] for i in range(n)]
t,a = tal[0][0],tal[0][1]
for i in range(1,n):
    quote = max(math.ceil(a/tal[i][1]),math.ceil(t/tal[i][0]))
    t = quote*tal[i][0]
    a = quote*tal[i][1]

print(a+t)

Submission status: Wrong Answer

Solution code:
def c_atcodeer_and_election_report(N, R):
    from math import ceil
    t = 1  # 高橋の票数
    a = 1  # 青木の票数
    for x, y in R:
        # t<=nx ∧ a<=ny を満たす最小のnを求める
        n = max(ceil(t / x), ceil(a / y))
        t = n * x
        a = n * y
    return t + a

N = int(input())
R = [[int(i) for i in input().split()] for j in range(N)]
print(c_atcodeer_and_election_report(N, R))

Submission status: Wrong Answer

Solution code:
N = int(input())
pro = [0,0,0]
for i in range(N):
    in_list = list(map(int,input().split()))
    in_list.append(in_list[0] + in_list[1])
    multi = 0
    for j in range(3):
        tem = int(pro[j]/in_list[j])
        if pro[j]%in_list[j] != 0 or pro[j] == 0:
            tem+=1
        if multi <tem:
            multi = tem
    pro[2] = multi*in_list[2]
    pro[0] = in_list[0]*multi
    pro[1] = in_list[1]*multi
print(pro[2])

Submission status: Wrong Answer

Solution code:
N = int(input())
min = 0;
pro = [1,1]
for i in range(N):
    in_list = list(map(int,input().split()))
    temp = in_list[0] + in_list[1]
    multi = int(max(pro[0]/in_list[0],pro[1]/in_list[1],min/temp))
    multi +=1
    if max((pro[0]-in_list[0]*(multi-1)),(pro[1]-in_list[1]*(multi-1)),(min-temp*(multi-1))) <= 0:
        multi -=1
        min = (multi)*temp
        pro[0] = in_list[0]*(multi)
        pro[1] = in_list[1]*(multi)
    else:
        min = (multi) * temp
        pro[0] = in_list[0] * (multi)
        pro[1] = in_list[1] * (multi)
print(min)