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:
n=int(input())
a,b=1,1
import math
for i in range(n):
    x,y=map(int,input().split())
    m=int(max(math.ceil(a/x),math.ceil(b/y)))
    a=m*x
    b=m*y
print(a+b)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
p = 1
q = 1
for _ in range(n):
    t, a = map(int, input().split())
    n = max(math.ceil(p / t), math.ceil(q / a))
    p = n * t
    q = n * a

print(p + q)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#ABC46 C

import math
n = int(input())
A,B = 1,1
for i in range(n):
    t,a = map(int,input().split())
    n = max(math.ceil(A/t),math.ceil(B/a))
    A,B = n*t,n*a
print(A+B)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#ABC46 C

import math
n = int(input())
A,B = 1,1
for i in range(n):
    a,t = map(int,input().split())
    n = max(math.ceil(A/a),math.ceil(B/t))
    A,B = n*a,n*t
print(A+B)

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = [[int(x) for x in input().split()] for _ in range(n)]

a,b= 1,1
from math import ceil
for i in range(n):
    k = int(max(ceil(a/ls[i][0]),ceil(b/ls[i][1])))
    a = int(ls[i][0]*k)
    b = int(ls[i][1]*k)
    
print(int(int(a)+int(b)))

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = [[int(x) for x in input().split()] for _ in range(n)]

a,b= 1,1
from math import ceil
for i in range(n):
    k = max(ceil(a/ls[i][0]),ceil(b/ls[i][1]))
    a = ls[i][0]*k
    b = ls[i][1]*k
    
print(a+b)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
x = 1
y = 1
for i in range(n):
    t, a = [int(_) for _ in input().split()]
    k = max(math.ceil(x/t), math.ceil(y/a))
    x = t*k
    y = a*k

print(x+y)

Submission status: Wrong Answer

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

print(x+y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil
N=int(input())
a,b=1,1
for _ in range(N):
    aa,bb=map(int,input().split())
    p,q=ceil(a/aa),ceil(b/bb)
    if p>=q:a,b=aa*p,bb*p
    else:a,b=aa*q,bb*q
print(a+b)

Submission status: Wrong Answer

Solution code:
# ABC046C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report (ARC062C)
import sys
input = sys.stdin.readline

from math import ceil


def main():
    n = int(input())
    arr = tuple(tuple(map(int, input().split())) for _ in range(n))
    t, a = 1, 1
    for i, j in arr:
        r = max(ceil(t / i), ceil(a / j))
        t, a = i * r, j * r
    print(t + a)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# ABC046C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report (ARC062C)
import sys
input = sys.stdin.readline

from math import ceil


def main():
    n = int(input())
    arr = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    t, a = 1, 1
    for i, j in arr:
        r = max(ceil(t / i), ceil(a / j))
        t, a = i * r, j * r
        print(t, a)
    print(t + a)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# ABC046C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report (ARC062C)
import sys
input = sys.stdin.readline

from math import ceil


def main():
    n = int(input())
    arr = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    t, a = arr[0]
    for i, j in arr[1:]:
        r = max(ceil(t / i), ceil(a / j))
        t, a = i * r, j * r
    print(t + a)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# ABC046C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report (ARC062C)
from math import ceil


def main():
    n = int(input())
    arr = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    t, a = arr[0]
    for i, j in arr[1:]:
        r = max(ceil(t / i), ceil(a / j))
        t, a = i * r, j * r
        print(t, a)
    print(t + a)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# 最小公倍数
# x,yに0が入ると0になるので、適当に初期値を入れましょう。(最悪1でいいと思います)
def lcm(x, y):
    import fractions
    return (x * y) // fractions.gcd(x, y)
n = int(input())
dat = []
import fractions

import math
for i in range(n):
    a, b = map(int, input().split())
    c = fractions.gcd(a, b)
    #a, b = a // c, b // c # 約分する
    dat.append( (a, b) )

(a, b) = 1,1
#print(dat)
import math
for i in range(n):
    x, y = dat[i]
    c = max(math.ceil(a / x), math.ceil(b / y))
    #print("{0},{1}: c= {4} : {2},{3}".format(x, y, a,b,c))
    a, b = x * c, y * c
print(a + b)

Submission status: Wrong Answer

Solution code:
# 最小公倍数
# x,yに0が入ると0になるので、適当に初期値を入れましょう。(最悪1でいいと思います)
def lcm(x, y):
    import fractions
    return (x * y) // fractions.gcd(x, y)
n = int(input())
dat = []
import fractions

import math
for i in range(n):
    a, b = map(int, input().split())
    c = fractions.gcd(a, b)
    a, b = a // c, b // c # 約分する
    dat.append( (a, b) )

(a, b) = 1,1
#print(dat)
import math
for i in range(n):
    x, y = dat[i]
    c = max(math.ceil(a / x), math.ceil(b / y))
    #print("{0},{1}: c= {4} : {2},{3}".format(x, y, a,b,c))
    a, b = x * c, y * c
print(a + b)

Submission status: Wrong Answer

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


t1 = 1
t2 = 1
for T1, T2 in ratio:
        tmp_a = int(t1 / T1 + 0.9)
        tmp_b = int(t2 / T2 + 0.9)
        n = int(max(tmp_a, tmp_b))
        t1 = n * T1 
        t2 = n * T2
print(t1 + t2)

Submission status: Wrong Answer

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


t1 = 1
t2 = 1
for T1, T2 in ratio:
        tmp_a = int(t1 / T1 + 0.9)
        tmp_b = int(t2 / T2 + 0.9)
        n = max(tmp_a, tmp_b)
        t1 = n * T1 
        t2 = n * T2
print(t1 + t2)

Submission status: Wrong Answer

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


t1 = 1
t2 = 1
for T1, T2 in ratio:
        if T1 == 1 and T2 == 1:
                t1 = max(t1, t2)
                t2 = max(t1, t2)
                continue
        elif T1 == 1:
                t2 = t1 * T2
                continue
        elif T2 == 1:
                t1 = t2 * T1
                continue
        while (t1 % T1 != 0 or int(t1 / T1 * T2) < t2):
                t1 += T1 - (t1 % T1)
        t2 = t1 / T1 * T2
print(int(t1 + t2))

Submission status: Wrong Answer

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


t1 = 1
t2 = 1
for T1, T2 in ratio:
        if T1 == 1 and T2 == 1:
                t1 = max(t1, t2)
                t2 = max(t1, t2)
                continue
        elif T1 == 1:
                t2 = t1 * T2
                continue
        elif T2 == 1:
                t1 = t2 * T1
                continue
        while (t1 % T1 != 0 or int(t1 / T1 * T2) < t2):
                t1 += 1
        t2 = t1 / T1 * T2
print(int(t1 + t2))

Submission status: Wrong Answer

Solution code:
N=int(input())
t=a=1
for i in range(N):
    T,A=map(int,input().split())
    num=max(-t//T,a//A)
    t,a=num*T,num*A
print(t+a)

Submission status: Wrong Answer

Solution code:
import math

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

print(t+a)

Submission status: Wrong Answer

Solution code:
import math

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

print(t+a)

Submission status: Wrong Answer

Solution code:
import math

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

print(t+a)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
T = []
A = []
for _ in range(N):
    t, a = map(int, input().split())
    T.append(t)
    A.append(a)

for i in range(1, N):
    val = max(math.ceil(T[i - 1] / T[i]), math.ceil(A[i - 1] / A[i]))
    T[i] *= val
    A[i] *= val
print(int(T[-1]) + int(A[-1]))

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
T = []
A = []
for _ in range(N):
    t, a = map(int, input().split())
    T.append(t)
    A.append(a)

for i in range(1, N):
    if T[i - 1] > T[i] or A[i - 1] > A[i]:
        val = max(math.ceil(T[i - 1] / T[i]), math.ceil(A[i - 1] / A[i]))
        T[i] *= val
        A[i] *= val
print(int(T[-1]) + int(A[-1]))

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
T = []
A = []
for _ in range(N):
    t, a = map(int, input().split())
    T.append(t)
    A.append(a)

for i in range(1, N):
    if T[i - 1] > T[i] or A[i - 1] > A[i]:
        t_r = math.ceil(T[i - 1] / T[i])
        a_r = math.ceil(A[i - 1] / A[i])

        if t_r > a_r:
            T[i] *= t_r
            A[i] *= t_r
        else:
            T[i] *= a_r
            A[i] *= a_r

print(int(T[-1]) + int(A[-1]))

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
T = []
A = []
for _ in range(N):
    t, a = map(int, input().split())
    T.append(t)
    A.append(a)

for i in range(1, N):
    t_r = math.ceil(T[i - 1] / T[i])
    a_r = math.ceil(A[i - 1] / A[i])

    if t_r > a_r:
        T[i] *= t_r
        A[i] *= t_r
    else:
        T[i] *= a_r
        A[i] *= a_r

print(int(T[-1]) + int(A[-1]))

Submission status: Wrong Answer

Solution code:
N = int(input())

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

tmp_T = 1
tmp_A = 1

for i in range(N):
    n = max(int((tmp_A + (A[i] - 1)) / A[i]), int((tmp_T + (T[i] - 1)) / T[i]))
    tmp_A = n * A[i]
    tmp_T = n * T[i]

print(tmp_T + tmp_A)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

tmp_T = T[0]
tmp_A = A[0]

for i in range(1,N):
    n = max(int((tmp_A + (A[i] - 1)) / A[i]), int((tmp_T + (T[i] - 1)) / T[i]))
    tmp_A = n * A[i]
    tmp_T = n * T[i]
    
print(tmp_T + tmp_A)

Submission status: Wrong Answer

Solution code:
N = int(input())
T = []
A = []
for i in range(N):
    B, C = map(int, input().split())
    T.append(B)
    A.append(C)
for i in range(N):
    if i == N - 1:
        if (T[i - 1] // A[i]) == 1:
            A[i] = A[i] * (T[i - 1] // T[i] + 1)
            T[i] = T[i] * (T[i - 1] // T[i] + 1)
        else:
            A[i] = A[i] * (T[i - 1] // T[i])
            T[i] = T[i] * (T[i - 1] // T[i])
    elif i == 0:
        pass
    elif T[i] < T[i - 1]:
        if (T[i - 1] // T[i] + 1) > (A[i - 1] // A[i] + 1):
            A[i] = A[i] * (T[i - 1] // T[i] + 1)
            T[i] = T[i] * (T[i - 1] // T[i] + 1)
        else:
            if T[i] == 1:
                T[i] = T[i] * (A[i - 1] // A[i])
                A[i] = A[i] * (A[i - 1] // A[i])
    elif T[i] < T[i - 1]:
        if (T[i - 1] // T[i] + 1) > (A[i - 1] // A[i] + 1):
            A[i] = A[i] * (T[i - 1] // T[i] + 1)
            T[i] = T[i] * (T[i - 1] // T[i] + 1)
        else:
            T[i] = T[i] * (A[i - 1] // A[i] + 1)
            A[i] = A[i] * (A[i - 1] // A[i] + 1)
    elif A[i] < A[i - 1]:
        if (T[i - 1] // T[i] + 1) < (A[i - 1] // A[i] + 1):
            T[i] = T[i] * (A[i - 1] // A[i] + 1)
            A[i] = A[i] * (A[i - 1] // A[i] + 1)
print(T[-1] + A[-1])

Submission status: Wrong Answer

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

T = 0
A = 0
for _ in range(N):
  next_T, next_A = [int(i) for i in input().split()]
  if next_T >= T and next_A >= A:
    T = int(next_T)
    A = int(next_A)
  else: 
    num = max(math.ceil(T/next_T), math.ceil(A/next_A))
    T = next_T * num
    A = next_A * num
print(int(sum([T, A])))

Submission status: Wrong Answer

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

T = 0
A = 0
for _ in range(N):
  next_T, next_A = [int(i) for i in input().split()]
  if next_T > T and next_A > A:
    T = int(next_T)
    A = int(next_A)
  else: 
    T = next_T * (max(math.ceil(T/next_T), math.ceil(A/next_A)))
    A = next_A * (max(math.ceil(T/next_T), math.ceil(A/next_A)))
print(int(sum([T, A])))

Submission status: Wrong Answer

Solution code:
n=int(input())

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

ans = t+a

for i in range(n-1):
    t,a=map(int, input().split())
    s=t+a
    ans = s * (ans // s + 1)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
T = []
A = []
for i in range(N):
    B, C = map(int, input().split())
    T.append(B)
    A.append(C)
for i in range(N):
    if i == N - 1:
        if (T[i - 1] // A[i]) == 1:
            A[i] = A[i] * (T[i - 1] // T[i] * 2)
            T[i] = T[i] * (T[i - 1] // T[i] * 2)
        else:
            A[i] = A[i] * (T[i - 1] // T[i])
            T[i] = T[i] * (T[i - 1] // T[i])
    elif i == 0:
        pass
    elif T[i] < T[i - 1]:
        if (T[i - 1] // T[i] + 1) > (A[i - 1] // A[i] + 1):
            A[i] = A[i] * (T[i - 1] // T[i] + 1)
            T[i] = T[i] * (T[i - 1] // T[i] + 1)
        else:
            if T[i] == 1:
                T[i] = T[i] * (A[i - 1] // A[i])
                A[i] = A[i] * (A[i - 1] // A[i])
    elif T[i] < T[i - 1]:
        if (T[i - 1] // T[i] + 1) > (A[i - 1] // A[i] + 1):
            A[i] = A[i] * (T[i - 1] // T[i] + 1)
            T[i] = T[i] * (T[i - 1] // T[i] + 1)
        else:
            T[i] = T[i] * (A[i - 1] // A[i] + 1)
            A[i] = A[i] * (A[i - 1] // A[i] + 1)
    elif A[i] < A[i - 1]:
        if (T[i - 1] // T[i] + 1) < (A[i - 1] // A[i] + 1):
            T[i] = T[i] * (A[i - 1] // A[i] + 1)
            A[i] = A[i] * (A[i - 1] // A[i] + 1)
print(T[-1] + A[-1])

Submission status: Wrong Answer

Solution code:
import math
import sys

N = int(sys.stdin.readline())
TA = []
for i in range(N):
    TA.append(list(map(int, sys.stdin.readline().split())))

current_T = 1
current_A = 1
for i in range(N):
    count = max(math.ceil(current_T/TA[i][0]), math.ceil(current_A/TA[i][1]))
    current_T = TA[i][0] * count
    current_A = TA[i][1] * count

print(current_T + current_A)

Submission status: Wrong Answer

Solution code:
import math
import sys

N = int(sys.stdin.readline())
TA = []
for i in range(N):
    TA.append(list(map(int, sys.stdin.readline().split())))

current_T = 1
current_A = 1
for i in range(N):
    count = max([math.ceil(current_T - 1//TA[i][0]), math.ceil(current_A - 1//TA[i][1])])
    current_T = TA[i][0] * count
    current_A = TA[i][1] * count

print(current_T + current_A)

Submission status: Wrong Answer

Solution code:
import math
import sys

N = int(sys.stdin.readline())
TA = []
for i in range(N):
    TA.append(list(map(int, sys.stdin.readline().split())))

current_T = 1
current_A = 1
for i in range(N):
    count = max([math.ceil(current_T/TA[i][0]), math.ceil(current_A/TA[i][1])])
    current_T = TA[i][0] * count
    current_A = TA[i][1] * count

print(current_T + current_A)

Submission status: Wrong Answer

Solution code:
import math
import sys

N = int(sys.stdin.readline())
TA = []
for i in range(N):
    TA.append(list(map(int, sys.stdin.readline().split())))

current_T = 0
current_A = 0
for i in range(N):
    if i == 0:
        current_T = TA[i][0]
        current_A = TA[i][1]
        continue
    count = max([math.ceil(current_T/TA[i][0]), math.ceil(current_A/TA[i][1])])
    current_T = TA[i][0] * count
    current_A = TA[i][1] * count

print(current_T + current_A)

Submission status: Wrong Answer

Solution code:
import math
import sys

N = int(sys.stdin.readline())
TA = []
for i in range(N):
    TA.append(list(map(int, sys.stdin.readline().split())))

current_T = 0
current_A = 0
for i in range(N):
    if i == 0:
        current_T = TA[i][0]
        current_A = TA[i][1]
        continue
    escape_flag = 0
    count = 1
    count = max([math.ceil(current_T/TA[i][0]), math.ceil(current_A/TA[i][1])])
#    while escape_flag == 0:
#        if TA[i][0] * count >= current_T and TA[i][1] * count >= current_A:
#            escape_flag =1
#        else:
#            count += 1
    current_T = TA[i][0] * count
    current_A = TA[i][1] * count

print(current_T+ current_A)

Submission status: Wrong Answer

Solution code:

N = int(input())

lst_S = []
for i in range(N):
    lst_S.append(input().split())
    lst_S[i][0] = int(lst_S[i][0])
    lst_S[i][1] = int(lst_S[i][1])


bote_A = lst_S[0][0]
bote_B = lst_S[0][1]

for i in range(1, N):
    A_w = lst_S[i][0]
    B_w = lst_S[i][1]
    while 1:
        if (A_w >= bote_A) and (B_w >= bote_B):
            break
        else:
            A_w += lst_S[i][0]
            B_w += lst_S[i][1]
    bote_A = A_w
    bote_B = B_w

ans = bote_A + bote_B

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def yakusuu(num):
    value=2
    _lst=[]
    print(num)
    while 1:
        if num==1:
            break
        while num%value==0:
            num=int(num/value)
            if value not in _lst:
                _lst.append(value)
        value+=1
    return(_lst)

def subtract_list(lst1, lst2):
    lst = lst1.copy()
    for element in lst2:
        if element in lst:
            lst.remove(element)
    return lst

def seki_list(lst):
    value=1
    for i in lst:
        value*=i
    return(value)


N=int(input())
data=[list(map(int,input().split())) for i in range(N)]
hyou=[data[0][0],data[0][1]]
print("======")
for i in range(N-1):

    if hyou[0]<=data[i+1][0] and hyou[1]<=data[i+1][1]:
        hyou[0]=data[i+1][0]
        hyou[1]=data[i+1][1]
    elif hyou[0]>data[i+1][0] and  hyou[1]>data[i+1][1]:
        div=max(int(hyou[0]/data[i+1][0]),int(hyou[1]/data[i+1][1]))
        hyou[0]=data[i+1][0]*div
        hyou[1]=data[i+1][1]*div
    elif hyou[0]>data[i+1][0] and hyou[1]<=data[i+1][1]:
        _subtract_list=subtract_list(yakusuu(data[i+1][0]),yakusuu(hyou[0]))
        _seki=seki_list(_subtract_list)
        hyou[0]=_seki*data[i+1][0]
        hyou[1]=_seki*data[i+1][1]
    elif hyou[0]<=data[i+1][0] and hyou[1]>data[i+1][1]:
        _subtract_list=subtract_list(yakusuu(data[i+1][1]),yakusuu(hyou[1]))
        _seki=seki_list(_subtract_list)
        hyou[0]=_seki*data[i+1][0]
        hyou[1]=_seki*data[i+1][1]
    #print(hyou,div)


print(sum(hyou))

Submission status: Wrong Answer

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

def current_result(t, a, x, y):
  #n = max(int(math.ceil(t/x)), int(math.ceil(a/y)))
  n = max(int((t-1)/x)+1, int((a-1)/y)+1)
  return n*x, n*y

if __name__ == "__main__":
  t, a = 1, 1
  for i in range(n):
    x, y = ta_li[i]
    t, a = current_result(t, a, x, y)
  print(t+a)

Submission status: Wrong Answer

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

def current_result(t, a, x, y):
  #n = max(int(math.ceil(t/x)), int(math.ceil(a/y)))
  n = max(int((t-1)/x)+1, int((a-1)/y)+1)
  return n*x, n*y

if __name__ == "__main__":
  t, a = 1, 1
  for i in range(n):
    x, y = ta_li[i]
    print(x, y)
    t, a = current_result(t, a, x, y)
  print(t+a)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
ta_li = [list(map(int, input().split())) for _ in range(n)]
t, a = 1, 1

def current_result(t, a, x, y):
  n = max(int(math.ceil(t/x)), int(math.ceil(a/y)))
  return n*x, n*y

if __name__ == "__main__":
  t, a = 1, 1
  for i in range(n):
    x, y = ta_li[i]
    t, a = current_result(t, a, x, y)
  print(t+a)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
ta_li = [list(map(int, input().split())) for _ in range(n)]
t, a = 1, 1

def current_result(t, a, x, y):
  n = max(math.ceil(t/x), math.ceil(a/y))
  return n*x, n*y

if __name__ == "__main__":
  t, a = 1, 1
  for i in range(n):
    x, y = ta_li[i]
    t, a = current_result(t, a, x, y)
  print(t+a)

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N = int(input())
TA = [[] for i in range(N)]
for i in range(N):
    TA[i] = [int(i) for i in input().split()]

min_T,min_A = 1,1
for i in range(N):
    t,a = TA[i]
    if min_T >= t or min_A>= a:
        multi = max(math.ceil(min_T / t),math.ceil(min_A/a))
        t,a = t*multi,a*multi
    min_T,min_A = t,a

print(min_A+min_T)

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N = int(input())
TA = [[] for i in range(N)]
for i in range(N):
    TA[i] = [int(i) for i in input().split()]

min_T,min_A = 1,1
for i in range(N):
    t,a = TA[i]
    if min_T >= t:
        multi = math.ceil(min_T / t)
        t,a = t*multi,a*multi
    if min_A >= a:
        multi = (math.ceil(min_A / a) )
        t,a = t*multi,a*multi

    t2,a2 = TA[i]
    if min_A >= a2:
        multi = (math.ceil(min_A / a2) )
        t2,a2 = t2*multi,a2*multi
    if min_T >= t2:
        multi = (math.ceil(min_T / t2) )
        t2,a2 = t2*multi,a2*multi

    if t2+a2 < t+a:
        min_T,min_A = t2,a2
    else:
        min_T,min_A = t,a

print(min_A+min_T)

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N = int(input())
TA = [[] for i in range(N)]
for i in range(N):
    TA[i] = [int(i) for i in input().split()]

min_T,min_A = TA[0]
for i in range(N):
    t,a = TA[i]
    if min_T > t:
        multi = math.ceil(min_T / t)
        t,a = t*multi,a*multi
    if min_A > a:
        multi = (math.ceil(min_A / a) )
        t,a = t*multi,a*multi

    t2,a2 = TA[i]
    if min_A > a2:
        multi = (math.ceil(min_A / a2) )
        t2,a2 = t2*multi,a2*multi
    if min_T > t2:
        multi = (math.ceil(min_T / t2) )
        t2,a2 = t2*multi,a2*multi

    if t2+a2 < t+a:
        min_T,min_A = t2,a2
    else:
        min_T,min_A = t,a

print(min_A+min_T)

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N = int(input())
TA = [[] for i in range(N)]
for i in range(N):
    TA[i] = [int(i) for i in input().split()]

min_T,min_A = TA[0]
for i in range(N):
    t,a = TA[i]
    if min_T > t:
        a *= (math.ceil(min_T / t))
        t *= (math.ceil(min_T / t) )
    if min_A > a:
        t *= (math.ceil(min_A / a) )
        a *= (math.ceil(min_A / a) )

    t2,a2 = TA[i]
    if min_A > a2:
        t2 *= (math.ceil(min_A / a2) )
        a2 *= (math.ceil(min_A / a2) )
    if min_T > t2:
        a2 *= (math.ceil(min_T / t2) )
        t2 *= (math.ceil(min_T / t2) )

    if t2+a2 < t+a:
        min_T,min_A = t2,a2
    else:
        min_T,min_A = t,a
    # print(min_T,min_A)

print(min_A+min_T)

Submission status: Wrong Answer

Solution code:
import itertools
from math import ceil
N = input()
N = int(N)
lasta,lastb = 1,1
temp = []
for _ in range(N):
    temp.append(list(map(int,input().split(" "))))


for hoge in temp:
    a,b = hoge
    diffa = ceil(lasta/a)
    diffb = ceil(lastb/b)
    diff = max(diffa,diffb)
    lasta,lastb = a*diff,b*diff
print(lasta+lastb)

Submission status: Wrong Answer

Solution code:
import itertools
from math import ceil
N = input()
N = int(N)
lasta,lastb = list(map(int,input().split(" ")))
temp = [[lasta,lastb]]
for _ in range(N-1):
    temp.append(list(map(int,input().split(" "))))


for hoge in temp:



    a,b = hoge
    diffa = ceil(lasta/a)
    diffb = ceil(lastb/b)
    diff = max(diffa,diffb)

    lasta,lastb = a*diff,b*diff
print(lasta+lastb)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
ta = [list(map(int,input().split())) for i in range(n)]

cur_t = 1
cur_a = 1

import math
for t,a in ta:
    if cur_t > t or cur_a > a:
        rate = math.ceil(max([cur_t/t,cur_a/a]))
        cur_t = t*rate
        cur_a = a*rate
    else:
        cur_t=t
        cur_a=a
print(cur_t+cur_a)

Submission status: Wrong Answer

Solution code:
from math import ceil


n = int(input())

a = 0
b = 0

for _ in range(n):
    x, y = map(int, input().split())
    if not a:
        a, b = x, y
        continue
    z = max(ceil(a / x), ceil(b / y))
    a, b = z * x, z * y

print(a + b)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import math



N = int(input())
tn,an = [1,1]
for _ in range(N):
  t,a = map(int, input().split())
  idx = max(math.ceil(tn/t),math.ceil(an/a))
  tn,an = [t*idx,a*idx]
print(tn+an)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import math



N = int(input())
tn,an = [1,1]
for _ in range(N):
  t,a = map(int, input().split())
  x = max(math.ceil(tn/t), math.ceil(an/a), 1)
  tn,an = [t*x,a*x]
print(tn+an)

Submission status: Wrong Answer

Solution code:
n = int(input())
TA = [list(map(int,input().split())) for _ in range(n)]

T,A = TA[0]
from math import ceil
for t,a in TA[1:]:
    N = max(ceil(T/t),ceil(A/a))
    T  = N*t
    A = N*a
print(A+T)

Submission status: Wrong Answer

Solution code:
n = int(input())
TA = [list(map(int,input().split())) for _ in range(n)]

T,A = 1,1
from math import ceil
for t,a in TA:
    N = max(ceil(T/t),ceil(A/a))
    T  = N*t
    A = N*a
print(A+T)

Submission status: Wrong Answer

Solution code:
from math import ceil

N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]

a = 1
b = 1
for x, y in TA:
    n = max(ceil(int(a) / int(x)), ceil(int(b) / int(y)))
    a = n * x
    b = n * y
print(a + b)

Submission status: Wrong Answer

Solution code:
from math import ceil

N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]

a = 1
b = 1
for x, y in TA:
    n = max(ceil(float(a) / float(x)), ceil(float(b) / float(y)))
    a = n * x
    b = n * y
print(a + b)

Submission status: Wrong Answer

Solution code:
from math import ceil
from decimal import Decimal

N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]

a = 1
b = 1
for x, y in TA:
    n = max(ceil(Decimal(a / x)), ceil(Decimal(b / y)))
    a = n * x
    b = n * y
print(a + b)

Submission status: Wrong Answer

Solution code:
from math import ceil

N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]

a = 1
b = 1
for x, y in TA:
    n = ceil(max(float(a / x), float(b / y)))
    a = n * x
    b = n * y
print(a + b)

Submission status: Wrong Answer

Solution code:
from math import ceil

N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]

a = 1
b = 1
for x, y in TA:
    n = max(ceil(float(a / x)), ceil(float(b / y)))
    a = n * x
    b = n * y
print(a + b)

Submission status: Wrong Answer

Solution code:
from math import ceil

N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]

a = 1
b = 1
for x, y in TA:
    n = max(ceil(float(a) / x), ceil(float(b) / y))
    a = n * x
    b = n * y
print(a + b)

Submission status: Wrong Answer

Solution code:
from math import ceil

N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]

a = 1
b = 1
for x, y in TA:
    n = max(ceil(a / x), ceil(b / y))
    a = n * x
    b = n * y
print(a + b)

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())
    multiplier = max(math.ceil(T / Ti), math.ceil(A / Ai))
    Ti *= multiplier
    Ai *= multiplier
    T, A = Ti, Ai
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())
    if Ti < T or Ai < A:
        multiplier = max(math.ceil(T / Ti), math.ceil(A / Ai))
        Ti *= multiplier
        Ai *= multiplier
    T, A = Ti, Ai
print(T + A)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
T, A = 0, 0
for i in range(N):
    Ti, Ai = map(int, input().split())
    t, a = Ti, Ai
    if t < T or a < A:
        multiplier = max(math.ceil(T / t), math.ceil(A / a))
        t = Ti * multiplier
        a = Ai * multiplier
    T, A = t, a
print(T + A)