fork(1) download
  1. $3{y=$1;while((x=(y*$2+1)/$3)%1?1:$1<x)y--;print x,y}
Success #stdin #stdout 0s 5288KB
stdin
3
1 1 1
5 2 5
5 3 2
50 48 49
6 0 1
5 1 2
stdout
1 0
1 2
5 3
49 50
1 6
3 5