Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		d, v := make([]int, 0), make([]int, 0)
		for i := 0; i < n; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			a, _ := strconv.Atoi(buf[0])
			b, _ := strconv.Atoi(buf[1])
			g := _gcd(a, b)
			a /= g
			b /= g
			d = append(d, a)
			v = append(v, b)
		}
		g := lcm(n, d)
		for i := 0; i < n; i++ {
			d[i] = (g/d[i])*v[i]
		}
		g = gcd(n, d)
		for i := 0; i < n; i++ {
			fmt.Println(d[i]/g)
		}
	}
}

func _gcd(a, b int) int {
	for b != 0 {
		r := a % b
		a, b = b, r
	}
	return a
}

func gcd(n int, a []int) int {
	if n == 1 {
		return a[0]
	}
	g := _gcd(a[0], a[1])
	for i := 2; i < n; i++ {
		if g == 1 {
			break
		}
		g = _gcd(g, a[i])
	}
	return g
}

func lcm(n int, a []int) int {
	if n == 1 {
		return a[0]
	}
	g := _gcd(a[0], a[1])
	c := a[0] / g * a[1]
	for i := 2; i < n; i++ {
		g = _gcd(c, a[i])
		c = c / g * a[i]
	}
	return c
}

Python: from fractions import gcd
from functools import reduce
from sys import stdin

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

while(True):
    n = int(stdin.readline())
    if not n: break
    s = [list(map(int,stdin.readline().split())) for _ in range(n)]
    lcmde = lcm_list([r[1] for r in s])
    lcmnu = lcm_list([r[0]*lcmde//r[1] for r in s])
    print("\n".join( str(lcmnu*r[1]//lcmde//r[0]) for r in s))

Python: from math import gcd
from functools import reduce

def gcd_mul(numbers):
    return reduce(gcd, numbers)

def lcm(x, y):
    return x * y // gcd(x, y)

def lcm_mul(numbers):
    return reduce(lcm, numbers)

def solve():
    from sys import stdin
    file_input = stdin
    
    from operator import mul
    
    while True:
        n = int(file_input.readline())
        if n == 0:
            break
        d_list = []
        v_list = []
        for i in range(n):
            d, v = map(int, file_input.readline().split())
            d_list.append(d)
            v_list.append(v)
        
        mv = reduce(mul, v_list)
        x = [mv * d // v for d, v in zip(d_list, v_list)]
        l = lcm_mul(x)
        
        for s in x:
            print(l // s)

solve()

Python: # -*- coding: utf-8 -*-
"""
Jogging
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0211

"""
import sys
from math import gcd
from functools import reduce

def solve(n, data):
    res = []
    for i in range(n):
        t = 1
        for j in range(n):
            t *= (data[j][0], data[j][1])[i==j]
        res.append(t)
    g = reduce(gcd, res)
    return [r//g for r in res]


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        data = [[int(i) for i in input().split()] for _ in range(n)]
        ans = solve(n, data)
        print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])

Python: import math

def lcm(x, y):
    return int((x * y) / math.gcd(x, y))


def mul_lcm(array):
    l = array[0]
    if len(array) > 1:
        for i in range(1, len(array)):
            l = lcm(array[i], l)

    return l


def algorithm(students, n):
    denominator_lcm = mul_lcm([y for _, y in students])
    for i in range(len(students)):
        students[i][0] *= int(denominator_lcm / students[i][1])
    molecular_lcm = mul_lcm([x for x, _ in students])

    return [int(molecular_lcm / students[i][0]) for i in range(len(students))]


def input_sample():
    while True:
        n = int(input())
        if n == 0:
            break

        students = [[-1, -1] for _ in range(20)]
        for i in range(n):
            students[i][0], students[i][1] = list(map(int, input().split()))
        answer_list = algorithm(students, n)

        for i in range(n):
            print(answer_list[i])


def main():
    input_sample()


if __name__ == '__main__':
    main()

Python: from fractions import gcd

def lcm(x, y):
    return (x * y) / gcd(x, y)


def mul_lcm(array):
    l = array[0]
    if len(array) > 1:
        for i in range(1, len(array)):
            l = lcm(array[i], l)

    return l


def algorithm(students, n):
    denominator_lcm = mul_lcm([y for _, y in students])
    for i in range(len(students)):
        students[i][0] *= int(denominator_lcm / students[i][1])
    molecular_lcm = mul_lcm([x for x, _ in students])

    return [int(molecular_lcm / students[i][0]) for i in range(len(students))]


def input_sample():
    while True:
        n = int(input())
        if n == 0:
            break

        students = [[-1, -1] for _ in range(20)]
        for i in range(n):
            students[i][0], students[i][1] = list(map(int, input().split()))
        answer_list = algorithm(students, n)

        for i in range(n):
            print(answer_list[i])


def main():
    input_sample()


if __name__ == '__main__':
    main()

Python: """ Created by Jieyi on 10/4/16. """
import io
import sys
import math

if len(sys.argv) > 1:
    filename = sys.argv[1]
    inp = ''.join(open(filename, "r").readlines())
    sys.stdin = io.StringIO(inp)


def lcm(x, y):
    return int((x * y) / math.gcd(x, y))


def mul_lcm(array):
    l = array[0]
    if len(array) > 1:
        for i in range(1, len(array)):
            l = lcm(array[i], l)

    return l


def algorithm(students, n):
    den = [students[i][1] for i in range(n)]
    denominator_lcm = mul_lcm(den)

    ans = [-1] * 20
    for i in range(n):
        ans[i] = students[i][0] * int(denominator_lcm / students[i][1])
    molecular_lcm = mul_lcm(ans[0:n])

    return [int(molecular_lcm / ans[i]) for i in range(n)]


def input_sample():
    while True:
        n = int(input())
        if n == 0:
            break

        # students = [[-1, -1] for _ in range(20)]
        # for i in range(n):
        #     students[i][0], students[i][1] = list(map(int, input().split()))
        students = [list(map(int, input().split(' '))) for _ in range(n)]
        answer_list = algorithm(students, n)

        for i in range(n):
            print(answer_list[i])


def main():
    input_sample()


if __name__ == '__main__':
    main()

Python: # AOJ 0211: Jogging
# Python3 2018.6.25 bal4u

def lcm(a, b):
	return a // gcd(a, b) * b

def gcd(a, b):
	while b != 0:
		r = a % b
		a, b = b, r
	return a

def ngcd(n, a):  # aが整数のリスト
	if n == 1: return a[0]
	g = gcd(a[0], a[1]);
	for i in range(2, n):
		if g == 1: break
		g = gcd(g, a[i])
	return g;

def nlcm(n, a):  # aが整数のリスト
	if n == 1: return a[0];
	g = gcd(a[0], a[1]);
	c = a[0] //g *a[1]
	for i in range(2, n):
		g = gcd(c, a[i])
		c = c //g * a[i]
	return c

while True:
	n = int(input())
	if n == 0: break
	d, v = [], []
	for i in range(n):
		a, b = map(int, input().split())
		g = gcd(a, b)
		a //= g
		b //= g
		d.append(a)
		v.append(b)
	g = nlcm(n, d);
	for i in range(n): d[i] = (g//d[i])*v[i]
	g = ngcd(n, d)
	for i in range(n): print(d[i]//g)

Python: from fractions import gcd
from functools import reduce
from sys import stdin

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

while(True):
    n = int(stdin.readline())
    if not n: break
    s = [list(map(int,stdin.readline().split())) for _ in range(n)]
    lcmde = lcm_list([r[1] for r in s])
    lcmnu = lcm_list([r[0]*lcmde//r[1] for r in s])
    print("\n".join( str(lcmnu*r[1]//lcmde//r[0]) for r in s))