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
}

C++: #include<bits/stdc++.h>
using namespace std;

long long int gcd(long long int a, long long int b);
long long int lcm(long long int a, long long int b);

int main(){
  int n;
  while(cin >> n , n){
    long long int d[11],v[11];
    for(int i=0;i<n;i++){
      cin >> d[i] >> v[i];
      long long int G = gcd(d[i],v[i]);
      d[i] /= G;
      v[i] /= G;
    }
    long long int L = lcm(d[0],d[1]);
    for(int i=2;i<n;i++){
      L = lcm(L,d[i]);
    }
    long long int ans[11];
    for(int i=0;i<n;i++){
      ans[i] = v[i]*(L/d[i]);
    }
    long long int G = gcd(ans[0],ans[1]);
    for(int i=2;i<n;i++){
      G = gcd(G,ans[i]);
    }
    for(int i=0;i<n;i++){
      cout << ans[i] / G << endl;
    }
  }
}

long long int gcd(long long int a, long long int b){
  if(b == 0) return a;
  else return gcd(b,a%b);
}

long long int  lcm(long long int a, long long int b){
  if(b > a) swap(a,b);
  return a * b / gcd(a,b);
}

C++: #include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

long long calc(long long x,long long y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

struct Student{
	long long int distance,speed;
};

int main(){

	int n;
	long long int c_speed,c_distance,work;
	Student students[10];

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		for(int i= 0; i < n; i++){
			scanf("%lld %lld",&students[i].distance,&students[i].speed);
			//?´??????????
			if(students[i].distance > students[i].speed){
				work = calc(students[i].distance,students[i].speed);
			}else{
				work = calc(students[i].speed,students[i].distance);
			}
			students[i].distance /= work;
			students[i].speed /= work;
		}

		//?????????????°???¬?????°????±???????

		//?????????????????§?????????????????????????????????????????????????°???¬?????°????±???????
		for(int i=0; i < n; i++){
			if(i == 0){
				c_speed = students[i].speed;
			}else{
				if(c_speed >= students[i].speed){
					work = calc(c_speed,students[i].speed);
					c_speed = ((c_speed/work)*students[i].speed);
				}else{
					work = calc(students[i].speed,c_speed);
					c_speed = ((c_speed/work)*students[i].speed);
				}
			}
		}

		//??????????????????????????????????????????
		for(int i=0; i < n; i++){
			students[i].distance *= (c_speed/students[i].speed);
		}

		//?¬?????????????????°???¬?????°????±???????
		for(int i=0; i < n; i++){
			if(i == 0){
				c_distance = students[i].distance;
			}else{
				if(c_distance >= students[i].distance){
					work = calc(c_distance,students[i].distance);
					c_distance = ((c_distance/work)*students[i].distance);
				}else{
					work = calc(students[i].distance,c_distance);
					c_distance = ((c_distance/work)*students[i].distance);
				}
			}
		}

		for(int i = 0; i < n; i++){
			students[i].distance = c_distance/students[i].distance;
		}

		//??????????????§??¬?´???°????±???????<?????????????????°??????>
		for(int i=0; i < n; i++){
			if(i == 0){
				work = students[i].distance;
			}else{
				if(work > students[i].distance){
					work = calc(work,students[i].distance);
				}else{
					work = calc(students[i].distance,work);
				}
			}
		}

		if(work == 0)work = 1;
		//??????????´??????????
		for(int i = 0; i < n; i++){
			students[i].distance /= work;
		}


		for(int i=0; i < n; i++){
			printf("%lld\n", students[i].distance);
		}
	}

    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

typedef pair<long long, long long> pl;

long long gcd(long long a, long long b) {
    return a == 0 ? b : gcd(b % a, a);
}

long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b;
}

void reduce(pl &a) {
    long long t = gcd(a.first, a.second);
    a.first /= t;
    a.second /= t;
}

pl lcm(pl a, pl b) {
    long long k = a.second, l = b.second;
    a.first *= l; a.second *= l;
    b.first *= k; b.second *= k;
    pl ret(a.first / gcd(a.first, b.first) * b.first, a.second);
    reduce(ret);
    return ret;
}

int main() {
    int n;
    while (cin >> n, n) {
        vector<long long> d(n), v(n);
        pl t;
        for (int i=0; i<n; ++i) {
            cin >> d[i] >> v[i];
            if (i == 0) {
                t = pl(d[i], v[i]);
            } else {
                t = lcm(t, pl(d[i], v[i]));
            }
        }
        for (int i=0; i<n; ++i) {
            cout << (t.first * v[i]) / (d[i] * t.second) << endl;
        }
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef unsigned long long int lli;
struct student{
  int d, v;
};
vector<student> vs;

lli __gcd(lli a, lli b){
  if(b == 0)return a;
  return __gcd(b, a%b);
}
lli __lcm(lli a, lli b){
  return a/__gcd(a, b)*b;
}
int main(int argc, char *argv[]){
  int n;
  while(std::cin >> n, n){
    vs.clear();
    lli lcm_v = 1, lcm_d = 1, lcm = 1;
    for (int i = 0; i < n; i++) {
      student s;
      std::cin >> s.d >> s.v;
      vs.push_back(s);
    }
    for (int i = 0; i < n; i++) {
      lcm_v = __lcm(lcm_v, vs[i].v);
      //std::cout << "lcm_v:" << lcm_v << std::endl;
    }
    for (int i = 0; i < n; i++) {
      lcm = __lcm(lcm, lcm_v/vs[i].v*vs[i].d);
      if(lcm_v%lcm == 0){
        lcm_v /= lcm;
        lcm = 1;
        //std::cout << "lcm_v:" << lcm_v << std::endl;
      }
      //std::cout << "lcm:" << lcm << std::endl;
    }
    for (int i = 0; i < n; i++) {
      std::cout << lcm/vs[i].d*vs[i].v/lcm_v<< std::endl;
    }
  }
  return 0;
}