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:
from math import ceil

def votes(t, a):
    votes_t = votes_a = 0
    for i in range(len(t)):
        if t[i] >= votes_t and a[i] >= votes_a:
            votes_t = max(votes_t, t[i])
            votes_a = max(votes_a, a[i])
        else:
            k = max(ceil(votes_t / t[i]), ceil(votes_a / a[i]))
            votes_t = t[i] * k
            votes_a = a[i] * k
    return votes_t + votes_a


if __name__ == '__main__':
    lines = [list(map(int, input().split())) for _ in range(int(input()))]
    t = [l[0] for l in lines]
    a = [l[1] for l in lines]
    print(votes(t, a))

Submission status: Wrong Answer

Solution code:
n=int(input())
t,a=map(int,input().split())
for i in range(1,n):
  c,d=map(int,input().split())
  e,f=c,d
  times=1
  while(e<t and f<a):
    times+=1
    e,f=c*times,d*times
  t,a=e,f
print(t+a)

Submission status: Wrong Answer

Solution code:
ans = 0
 
for i in range(int(input())):
    t_i, a_i = list(map(lambda x: int(x), input().split()))
 
    if i == 0:
        t, a = t_i, a_i
 
    else:
        n = max((t + t_i - 1) // t_i, (a + a_i - 1) // a_i)
        t = n*t_i
        a = n*a_i
 
    ans = t + a

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
min_a=1
min_b=1
for i in range(N):
  a,b=map(int,input().split())
  if min_a > a or min_b > b:
    min_a=a*max(int(math.ceil(min_a/a)),int(math.ceil(min_b/b)))
    min_b=b*max(int(math.ceil(min_a/a)),int(math.ceil(min_b/b)))
  else:
    min_a=a
    min_b=b
print(min_a+min_b)

Submission status: Wrong Answer

Solution code:
def c_AtCoDeer_and_ElectionReport(N, R):
    from math import ceil
    t = 1  # 高橋の票数
    a = 1  # 蒼きの票数
    for x, y in R:
        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_ElectionReport(N, R))

Submission status: Wrong Answer

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

for t, a in TA:
    z = max(ceil(T/t), ceil(A/a))
    T = t * z
    A = a * z

print(T+A)

Submission status: Wrong Answer

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

ans = 0
pre_t = 0
pre_a = 0

for t, a in TA:
    gcdd = gcd(t, a)

    t = t * gcdd
    a = a * gcdd

    if (pre_t > t) or(pre_a > a):
        for i in range(1, 10000):
            if (t*i >= pre_t) & (a*i >= pre_a):
                t *= i
                a *= i
                break
    pre_t = t
    pre_a = a

print(t + a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N=input()
x=[ tuple(map(int,raw_input().split())) for _ in range(N)]
#print x
R=[]

for i in range(N):
	if i==0:
		R.append(x[i][0])
		R.append(x[i][1])
	else:
		#print x[i][0],R[0],x[i][1],R[1]
		if x[i][0]>=R[0] and x[i][1]>=R[1]:
			R[0]=x[i][0]
			R[1]=x[i][1]
		else:
			v1= float(R[0])/x[i][0] 
			v2= float(R[1])/x[i][1]
			#print v1,v2
			R[0]=x[i][0]*int(math.ceil(max(v1,v2)))
			R[1]=x[i][1]*int(math.ceil(max(v1,v2)))
	#print R

print sum(R)

Submission status: Wrong Answer

Solution code:
import math
N=input()
x=[ tuple(map(int,raw_input().split())) for _ in range(N)]
#print x
R=[]

for i in range(N):
	if i==0:
		R.append(x[i][0])
		R.append(x[i][1])
	else:
		#print x[i][0],R[0],x[i][1],R[1]
		if x[i][0]>=R[0] and x[i][1]>=R[1]:
			R[0]=x[i][0]
			R[1]=x[i][1]
		else:
			v1= math.ceil( float(R[0])/x[i][0] ) 
			v2= math.ceil( float(R[1])/x[i][1] ) 
			R[0]=x[i][0]*int(max(v1,v2))
			R[1]=x[i][1]*int(max(v1,v2))
	#print R

print sum(R)

Submission status: Wrong Answer

Solution code:
import math
N=input()
x=[ tuple(map(int,raw_input().split())) for _ in range(N)]
#print x
R=[]

for i in range(N):
	if i==0:
		R.append(x[i][0])
		R.append(x[i][1])
	else:
		if x[i][0]>=R[0] and x[i][1]>=R[1]:
			R[0]=x[i][0]
			R[1]=x[i][1]
		else:
			v1= int( math.ceil( float(R[0])/x[i][0] ) )
			v2= int( math.ceil( float(R[1])/x[i][1] ) )
			R[0]=x[i][0]*max(v1,v2)
			R[1]=x[i][1]*max(v1,v2)
	#print R

print sum(R)

Submission status: Wrong Answer

Solution code:
n = int(input())

tnum = 1
anum = 1
for i in range(n):
    t, a = list(map(int, input().split()))
    amari = 0
    if t >= a:
        if anum > a:
            amari = anum % a
        else:
            anum = a
        if amari != 0:
            anum += (a - amari)
        newtnum = t * (anum / a)
        if tnum > newtnum:
            if tnum > t:
                amari = tnum % t
            else:
                tnum = t
            amari = tnum % t
            if amari != 0:
                tnum += (t - amari)
            anum = (tnum / t) * a
        else:
            tnum = newtnum
    else:
        if tnum > t:
            amari = tnum % t
        else:
            tnum = t
        amari = tnum % t
        if amari != 0:
            tnum += (t - amari)
        newanum = (tnum / t) * a
        if newanum < anum:
            if anum > a:
                amari = anum % a
            else:
                anum = a
            if amari != 0:
                anum += (a - amari)
            tnum = t * (anum / a)
        else:
            anum = newanum
    #print(tnum)
    #print(anum)

print(int(anum + tnum))

Submission status: Wrong Answer

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

A=1
T=1
for i in range(N):
  t, a = [int(n) for n in input().split()]
  n = max(math.ceil(T/t), math.ceil(A/a))
  T = n*t
  A = n*a

print(A+T)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
ta = [list(map(int, input().split())) for i in range(n)]

t = 1
a = 1

for i in range(n):
    x = max(math.ceil(t/ta[i][0]), math.ceil(a/ta[i][1]))
    t = ta[i][0] * x
    a = ta[i][1] * x

print(t+a)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
ta = [list(map(int, input().split())) for i in range(n)]

t = ta[0][0]
a = ta[0][1]

for i in range(n):
    if t / ta[i][0] >= a / ta[i][1]:
        t = ta[i][0] * math.ceil(t/ta[i][0])
        a = ta[i][1] * math.ceil(t/ta[i][0])
    else:
        t = ta[i][0] * math.ceil(a/ta[i][1])
        a = ta[i][1] * math.ceil(a/ta[i][1])

print(int(t+a))

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
ta = [list(map(int, input().split())) for i in range(n)]

t = ta[0][0]
a = ta[0][1]

for i in range(n):
    if t / ta[i][0] >= a / ta[i][1]:
        t = ta[i][0] * math.ceil(t/ta[i][0])
        a = ta[i][1] * math.ceil(t/ta[i][0])
    else:
        t = ta[i][0] * math.ceil(a / ta[i][1])
        a = ta[i][1] * math.ceil(a / ta[i][1])

print(t+a)

Submission status: Wrong Answer

Solution code:

num_times_checked = int(input())
votes_t = 0
votes_a = 0
for i in range(num_times_checked):
    vals = input().split(' ')
    ratio = (int(vals[0]), int(vals[1])) # T:A
    if ((ratio[0] > votes_t and ratio[1] > votes_a)):
        votes_t = ratio[0]
        votes_a = ratio[1]
    else:
        new_t = ratio[0]
        new_a = ratio[1]
        ratio_t = float(votes_t) / new_t
        ratio_a = float(votes_a) / new_a
        ratio_max = max(ratio_t, ratio_a)
        ratio_max = int( ratio_max + (0 if ratio_max % 1 == 0 else 1)) 
         
        votes_t = int(new_t * ratio_max)
        votes_a = int(new_a * ratio_max)

print(str( votes_t + votes_a ))

Submission status: Wrong Answer

Solution code:
num_times_checked = int(input())
votes_t = 0
votes_a = 0
for i in range(num_times_checked):
    vals = input().split(' ')
    ratio = (int(vals[0]), int(vals[1])) # T:A
    if (votes_t + votes_a == 0):
        votes_t = ratio[0]
        votes_a = ratio[1]
    else:
        new_t = ratio[0]
        new_a = ratio[1]
        ratio_t = float(votes_t) / new_t
        ratio_a = float(votes_a) / new_a
        ratio_max = max(ratio_t, ratio_a)
        ratio_max = int( ratio_max + (0 if ratio_max % 1 == 0 else 1)) 
         
        votes_t = new_t * ratio_max
        votes_a = new_a * ratio_max

print(str( votes_t + votes_a ))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import math
from decimal import Decimal


def main():
    N = int(input())
    t, a = map(int, input().split())
    t, a = Decimal(t), Decimal(a)
    for _ in range(N - 1):
        T, A = map(int, input().split())
        p = max(math.ceil(t / T), math.ceil(a / A))
        t, a = T * p, A * p
    print(t + a)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import math


def main():
    N = int(input())
    t, a = map(int, input().split())
    for _ in range(N - 1):
        T, A = map(int, input().split())
        p = max(math.ceil(t / T), math.ceil(a / A))
        t, a = T * p, A * p
    print(t + a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

t, a = list(map(int, input().split()))

for i in range(N-1):
    T, A = list(map(int, input().split()))
    if T > A:
        while(1):
            if (T*1.0/A)*a == int((T*1.0/A)*a):
                t = (T*1.0/A)*a
                break
            a += 1
    elif T == A:
        t = max(t, a)
        a = max(t, a)
    elif T < A:
        while(1):
            if (A*1.0/T)*t == int((A*1.0/T)*t):
                a = (A*1.0/T)*t
                break
            t += 1
print(int(a+t))

Submission status: Wrong Answer

Solution code:
from math import ceil
N = int(input())
nums = [int(x) for x in input().split()]
A,B = nums[0],nums[1]

for i in range(N-1):
	nums = [int(x) for x in input().split()]
	x,y = nums[0],nums[1]
	n = max(ceil(A/x),ceil(B/y))
	A,B = x*n, y*n
print(A+B)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math

n = input()
vote_t = 1
vote_a = 1
for i in range(n):
    t,a = map(int,raw_input().split())
    multiple_t = math.ceil(1.0*vote_t / t)
    multiple_a = math.ceil(1.0*vote_a / a)
    multiple = max(multiple_t,multiple_a)
    vote_t = t*multiple
    vote_a = a*multiple
print(int(vote_t + vote_a))

Submission status: Wrong Answer

Solution code:
import sys
import math
 
n = list(map(int,input()))[0]
T,A = 1,1
for i in range(n):
    t,a = map(int,input().split(" "))
    coef = max((T+t-1)//t,(A+a-1)//a)
    T,A = coef * t, coef * a 
print(T+A)

Submission status: Wrong Answer

Solution code:
import sys
import math

n = list(map(int,input()))[0]
T,A = 1,1
for i in range(n):
    t,a = map(int,input().split(" "))
    coef = max((T+t-1)//t,(A+a-1)//a)
    T,A = coef * t, coef * a 
print(T+A)

Submission status: Wrong Answer

Solution code:
import sys
import math

n = list(map(int,input()))[0]
T,A = 1,1
for i in range(n):
    tmp = list(map(int,input().split(" ")))
    t, a = tmp[0], tmp[1]
    coef = max((T+t-1)//t,(A+a-1)//a)
    T,A = coef * t, coef * a 
print(T+A)

Submission status: Wrong Answer

Solution code:
import sys
import math

n = list(map(int,input()))[0]
T = 0
A = 0
for i in range(n):
    tmp = list(map(int,input().split(" ")))
    t = tmp[0]
    a = tmp[1]
    if i == 0:
        T = t
        A = a
    else:
        coef = max((T+t-1)//t,(A+a-1)//a)
        T = coef * t 
        A = coef * a 
print(T+A)

Submission status: Wrong Answer

Solution code:
import sys
import math

n = list(map(int,input()))[0]
T = 0
A = 0
for i in range(n):
    tmp = list(map(int,input().split(" ")))
    t = tmp[0]
    a = tmp[1]
    if i == 0:
        T = t
        A = a
    else:
        coef = max(math.ceil(T/float(t)),math.ceil(A/float(a)))
        T = coef * t 
        A = coef * a 
print(T+A)

Submission status: Wrong Answer

Solution code:
import sys
import math

n = list(map(int,input()))[0]
T = 0
A = 0
for i in range(n):
    tmp = list(map(int,input().split(" ")))
    t = tmp[0]
    a = tmp[1]
    if i == 0:
        T = t
        A = a
    else:
        coef = max(math.ceil(T/t),math.ceil(A/a))
        T = coef * t 
        A = coef * a 
print(T+A)

Submission status: Wrong Answer

Solution code:
import sys
import math

n = list(map(int,input()))[0]
T = 0
A = 0
for i in range(n):
    tmp = list(map(int,input().split(" ")))
    t = tmp[0]
    a = tmp[1]
    if i == 0:
        T = t
        A = a
    else:
        coef = max(math.ceil(T//t),math.ceil(A//a))
        T = coef * t 
        A = coef * a 
print(T+A)

Submission status: Wrong Answer

Solution code:
import sys
import math

n = list(map(int,input()))[0]
T = 0
A = 0
for i in range(n):
    tmp = list(map(int,input().split(" ")))
    t = tmp[0]
    a = tmp[1]
    if i == 0:
        T = t
        A = a
    else:
        coef = max([math.ceil(T/t),math.ceil(A/a)])
        T = coef * t
        A = coef * a
print(str(T+A))

Submission status: Wrong Answer

Solution code:
from math import ceil

n = int(input())
    
t_num , a_num = 1, 1
for t, a in [map(int, input().split()) for _ in range(n)]:
    pre_t_num, pre_a_num = t_num, a_num
    t_num, a_num = t, a
    if t_num < pre_t_num or a_num < pre_a_num:
        # t_k = (pre_t_num + t - 1) // t
        # a_k = (pre_a_num + a - 1) // a
        t_k = ceil(pre_t_num / t)
        a_k = ceil(pre_a_num / a)
        m = max(t_k, a_k)
        t_num, a_num = t * m, a * m

ans = t_num + a_num
print()
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil

n = int(input())

t_num , a_num = 1, 1
for t, a in [map(int, input().split()) for _ in range(n)]:
    pre_t_num, pre_a_num = t_num, a_num
    t_num, a_num = t, a
    if t_num < pre_t_num or a_num < pre_a_num:
        t_k = ceil(pre_t_num / t)
        a_k = ceil(pre_a_num / a)
        m = max(t_k, a_k)
        t_num, a_num = t * m, a * m

ans = t_num + a_num
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

t_num , a_num = map(int, input().split())
f = False
for t, a in [map(int, input().split()) for _ in range(n-1)]:
    pre_t_num, pre_a_num = t_num, a_num
    t_num, a_num = t, a
    if t_num < pre_t_num or a_num < pre_a_num:
        f = True
        m = max(pre_t_num // t + 1, pre_a_num // a + 1)
        t_num, a_num = t * m, a * m

ans = t_num + a_num
if f:
    ans -= (t + a)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
T = []
A = []
Nb = 0
for i in range(N):
    a, b = map(int,input().split())
    T.append(a)
    A.append(b)
Tn = 1
An = 1
for i in range(N):
        tmp = max(math.ceil(Tn / T[i]), math.ceil(An / A[i]))
        Tn = T[i] * tmp
        An = A[i] * tmp
print(Tn + An)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
T = []
A = []
Nb = 0
for i in range(N):
    a, b = map(int,input().split())
    T.append(a)
    A.append(b)
Tn = T[0]
An = A[0]
for i in range(N):
        tmp = math.ceil(max(Tn / T[i], An / A[i]))
        Nb = (T[i] + A[i])*tmp
        Tn = T[i] * tmp
        An = A[i] * tmp
print(Nb)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
T = []
A = []
Nb = 0
for i in range(N):
    a, b = map(int,input().split())
    T.append(a)
    A.append(b)
Tn = T[0]
An = A[0]
for i in range(N):
    if T[i] >= Tn and A[i] >= An :
        Nb = T[i] + A[i]
        Tn = T[i]
        An = A[i]
    else:
        tmp = math.ceil(min(Tn / T[i], An / A[i]))
        if T[i] * tmp < Tn or A[i] * tmp < An:
            tmp = math.ceil(max(Tn / T[i], An / A[i]))
        Nb = (T[i] + A[i])*tmp
        Tn = T[i] * tmp
        An = A[i] * tmp
print(Nb)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
T = []
A = []
Nb = 0
for i in range(N):
    a, b = map(int,input().split())
    T.append(a)
    A.append(b)
Tn = T[0]
An = A[0]
for i in range(N):
    if T[i] >= Tn and A[i] >= An :
        Nb = T[i] + A[i]
        Tn = T[i]
        An = A[i]
    else:
        tmp = math.ceil(max(Tn / T[i], An / A[i]))
        Nb = (T[i] + A[i])*tmp
        Tn = T[i] * tmp
        An = A[i] * tmp
print(Nb)

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
t,a=1,1
for i in range(n):
    ti,ai=map(int,input().split())
    m=max(math.ceil(t/ti), math.ceil(a/ai))
    while t <= ti*(m-1) and a <= ai*(m-1):
        m-=1
    t,a=ti*m,ai*m
print(t+a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import math
N = int(input())
A, B = (1, 1)
for tmp in range (N):
    t, a = map(int,input().split())
    n = max([math.ceil(A/t),math.ceil(B/a)])
    A = n*t
    B = n*a
print(A+B)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import math
N = int(input())
A, B = (1, 1)
for tmp in range (N):
    t, a = map(int,input().split())
    n = max(math.ceil(A/t),math.ceil(B/a))
    A = n*t
    B = n*a
print(A+B)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import math
N = int(input())
TA = []
A, B = (1, 1)
for tmp in range (N):
    TA.append(list(map(int,input().split())))

for tmp in range (N):
    n = max(math.ceil(A/TA[tmp][0]),math.ceil(B/TA[tmp][1]))
    A = n*TA[tmp][0]
    B = n*TA[tmp][1]
print(A+B)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
T = [0 for i in range(N)]
A = [0 for i in range(N)]
for i in range(N):
	T[i], A[i] = map(int, input().split())

minT = T[0]
minA = A[0]

for i in range(1, N):
	tmpT = T[i]
	tmpA = A[i]
	# rate = 1
	rate = max(math.ceil(minT/tmpT), math.ceil(minA/tmpA))
	# if tmpT<minT or tmpA<minA:
		# rate = max(int((minT-1)/tmpT)+1, int((minA-1)/tmpA)+1)
		# rate = max(math.ceil(minT/tmpT), math.ceil(minA/tmpA))
	minT = tmpT*rate
	minA = tmpA*rate
print(minT+minA)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
T = [0 for i in range(N)]
A = [0 for i in range(N)]
for i in range(N):
	T[i], A[i] = map(int, input().split())

minT = T[0]
minA = A[0]

for i in range(1, N):
	tmpT = T[i]
	tmpA = A[i]
	rate = 1
	if tmpT<minT or tmpA<minA:
		# rate = max(int((minT-1)/tmpT)+1, int((minA-1)/tmpA)+1)
		rate = max(math.ceil(minT/tmpT), math.ceil(minA/tmpA))
	minT = tmpT*rate
	minA = tmpA*rate
print(minT+minA)

Submission status: Wrong Answer

Solution code:
N = int(input())
T = [0 for i in range(N)]
A = [0 for i in range(N)]
for i in range(N):
	T[i], A[i] = map(int, input().split())

minT = T[0]
minA = A[0]

for i in range(1, N):
	tmpT = T[i]
	tmpA = A[i]
	rate = 1
	if tmpT<minT or tmpA<minA:
		rate = max(int((minT-1)/tmpT)+1, int((minA-1)/tmpA)+1)
	minT = tmpT*rate
	minA = tmpA*rate
print(minT+minA)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from itertools import count
from math import ceil

def main():
    n = int(input())
    A, B = map(int, input().split())
    for _ in range(n - 1):
        t, a = map(int, input().split())
        n = max(ceil(A / t), ceil(B / a))
        A, B = n * t, n * a

    print(A + B)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

N=int(input())


result=[]
trueresult=[]

for i in range(N):
    put=input().split(" ")
    takahashi=int(put[0])
    aoki=int(put[1])
    result.append([takahashi,aoki])






for i in range(1,N):
    k=1
    if result[i][0]<result[i-1][0] or result[i][1]<result[i-1][1]:
        k=max(math.ceil(result[i-1][0]/result[i][0]),math.ceil(result[i-1][1]/result[i][1]))
    result[i][0]*=k
    result[i][1]*=k


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

Submission status: Wrong Answer

Solution code:
import math

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

a = ta[0][0]
b = ta[0][1]
for i in range(1, n):
    n = max(math.ceil(a/ta[i][0]), math.ceil(b/ta[i][1]))
    a = n * ta[i][0]
    b = n * ta[i][1]

print(a+b)

Submission status: Wrong Answer

Solution code:
import math

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

a = ta[0][0]
b = ta[0][1]
for i in range(1, n):
    tempa = ta[i][0]
    tempb = ta[i][1]

    if(a/tempa >= b/tempb):
        j = math.ceil(a/tempa)
        a = j*tempa
        b = j*tempb
    else:
        j = math.ceil(b/tempb)
        a = j*tempa
        b = j*tempb

print(a+b)

Submission status: Wrong Answer

Solution code:
n = int(input())
t = 1
a = 1
for i in range(n):
    T, A = map(int, input().split())
    k = max(1, t // T + (0 if t // T == 0 else 1), a // A + (0 if a // A == 0 else 1))
    t = k * T
    a = k * A
print(t + a)

Submission status: Wrong Answer

Solution code:
n = int(input())
t = 1
a = 1
for i in range(n):
    T, A = map(int, input().split())
    k = max(t // T + (0 if t // T == 0 else 1), a // A + (0 if a // A == 0 else 1))
    t = k * T
    a = k * A
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 = map(int, input().split())
    k = max(math.ceil(t / T), math.ceil(a / A))
    t = k * T
    a = k * A
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 = map(int, input().split())
    if t <= T and a <= A:
        t = T
        a = A
    else:
        k = max(-int(-t / T), -int(-a / A))
        t = k * T
        a = k * A
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 = map(int, input().split())
    if t <= T and a <= A:
        t = T
        a = A
    else:
        k = max(math.ceil(t / T), math.ceil(a / A))
        t = k * T
        a = k * A
print(t + a)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
T = A = 1
for _ in range(N):
    t, a = map(int, input().split())
    k = max([1, int(math.ceil(T / t)), int(math.ceil(A / a))])
    T, A = k * t, k * a
print(T + A)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import math
N=int(input())

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

    if T<=t_i and A<=a_i:
        T,A=t_i,a_i
    else:
        raito=max(math.ceil(T/t_i),math.ceil(A/a_i))
        T,A=t_i*raito,a_i*raito

print(T+A)

Submission status: Wrong Answer

Solution code:
import math as ma

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

for i in range(N):
	kmax = ma.ceil(max(t/l[i][0], a/l[i][1]))
	t = kmax * l[i][0]
	a = kmax * l[i][1]

print(t + a)

Submission status: Wrong Answer

Solution code:
import math as ma

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

kmax = 0

for i in range(N-1):
	kmax = ma.ceil(max(l[i][0] / l[i+1][0], l[i][1] / l[i+1][1]))
	l[i+1][0] = kmax * l[i+1][0]
	l[i+1][1] = kmax * l[i+1][1]
		
print(l[N-1][0]+l[N-1][1])

Submission status: Wrong Answer

Solution code:
import math as ma

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

kmax = 0

for i in range(N-1):
	if l[i+1][0] >= l[i][0] and l[i+1][1] >= l[i][1]:
		continue
	else:
		kmax = ma.ceil(max(l[i][0] / l[i+1][0], l[i][1] / l[i+1][1]))
		l[i+1][0] = kmax * l[i+1][0]
		l[i+1][1] = kmax * l[i+1][1]
		
print(l[N-1][0]+l[N-1][1])

Submission status: Wrong Answer

Solution code:
from math import ceil
from fractions import Fraction


def main():
    N = int(input())
    t, a = 1, 1
    for _ in range(N):
        _t, _a = map(int, input().split())
        n = ceil(max(Fraction(t / _t), Fraction(a / _a)))
        t, a = _t * n, _a * n
    print(t + a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import Fraction


def main():
    N = int(input())
    t, a = 1, 1
    for _ in range(N):
        _t, _a = map(int, input().split())
        n = max(Fraction(t / _t), Fraction(a / _a))
        t, a = _t * n, _a * n
    print(t + a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
from decimal import Decimal


def main():
    N = int(input())
    t, a = 1, 1
    for _ in range(N):
        _t, _a = map(int, input().split())
        n = int(max(math.ceil(t / _t), math.ceil(a / _a)))
        t, a = _t * n, _a * n

    print(t + a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math


def main():
    N = int(input())
    t, a = 1, 1
    for _ in range(N):
        _t, _a = map(int, input().split())
        n = max(math.ceil(t / _t), math.ceil(a / _a))
        t, a = _t * n, _a * n

    print(t + a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

from math import *

N = int(input())
T, A = 1, 1

for i in range(N):
	t, a = list(map(int, input().split()))
	n = max(ceil(T / t), ceil(A / a))
	T = n * t
	A = n * a

print(T + A)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def fceil(X, x):
	if X % x == 0:
		return int(X / x)
	else:
		return int(X / x) + 1

N = int(input())
T, A = 1, 1

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

print(int(T + A))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

from math import *

N = int(input())
T, A = 1, 1

for i in range(N):
	t, a = list(map(int, input().split()))
	n = max(ceil(T / t), ceil(A / a))
	T = n * t
	A = n * a

print(int(T + A))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

from math import *

N = int(input())
T, A = list(map(int, input().split()))

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

print(int(T + A))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
N=input()
T=[]
A=[]
for i in range(N):
    Ti,Ai=map(int,raw_input().split())
    T.append(Ti)
    A.append(Ai)
 
Tn=1
An=1
dp = np.zeros(N)
dp[0] = 1
 
for i in range(1,N):
    dp[i] = math.ceil(max(A[i]/A[i-1],T[i]/T[i-1])*dp[i-1])
 
print (T[-1]+A[-1])*dp[-1]

Submission status: Wrong Answer

Solution code:
from sys import setrecursionlimit
from numpy import ceil


def _main():
    setrecursionlimit(1100)
    print int(sum(election(1.0, 1.0, input())))


def election(t_prev, a_prev, n):
    if n == 0:
        return t_prev, a_prev
    t, a = map(int, raw_input().split())

    mlt = float(max(ceil(t_prev / t), ceil(a_prev / a), 1))
    return election(mlt * t, mlt * a, n - 1)


if __name__ == '__main__':
    _main()

Submission status: Wrong Answer

Solution code:
from sys import setrecursionlimit
from numpy import ceil


def _main():
    setrecursionlimit(1100)
    print int(sum(election(1.0, 1.0, input())))


def election(t_prev, a_prev, n):
    if n == 0:
        return t_prev, a_prev
    t, a = map(int, raw_input().split())

    mlt = max(ceil(t_prev / t), ceil(a_prev / a), 1.0)
    return election(mlt * t, mlt * a, n - 1)


if __name__ == '__main__':
    _main()

Submission status: Wrong Answer

Solution code:
from sys import setrecursionlimit
from numpy import ceil


def _main():
    setrecursionlimit(1100)
    print int(sum(election(1.0, 1.0, input())))


def election(t_prev, a_prev, n):
    if n == 0:
        return t_prev, a_prev
    t, a = map(int, raw_input().split())

    mlt = max(ceil(t_prev / t), ceil(a_prev / a), 1.0)
    return election(t * mlt, a * mlt, n - 1)


if __name__ == '__main__':
    _main()

Submission status: Wrong Answer

Solution code:
from sys import setrecursionlimit
from numpy import ceil


def _main():
    setrecursionlimit(1100)
    print int(sum(election(1.0, 1.0, input())))


def election(t_prev, a_prev, n):
    if n == 0:
        return t_prev, a_prev
    t, a = map(int, raw_input().split())

    mlt = max(ceil(t_prev / t), ceil(a_prev / a), 1)
    return election(t * mlt, a * mlt, n - 1)


if __name__ == '__main__':
    _main()

Submission status: Wrong Answer

Solution code:
from numpy import ceil


def _main():
    print int(sum(election(1.0, 1.0, input())))


def election(t_prev, a_prev, n):
    if n == 0:
        return t_prev, a_prev
    t, a = map(int, raw_input().split())

    mlt = max(ceil(t_prev / t), ceil(a_prev / a), 1)
    return election(t * mlt, a * mlt, n - 1)


if __name__ == '__main__':
    _main()

Submission status: Wrong Answer

Solution code:
import math as m
p=q=1.0
for i in range(0,int(raw_input())):
  r,s=map(int, raw_input().split())
  t=max(m.ceil(p/r),m.ceil(q/s))
  p=r*t
  q=s*t
print int(p+q)