s=$3{for(y=$1;(x=(y*$2+1)/s)%1+c;y--)c=$1<x;print x,y}
1 1 1 5 2 5 5 3 2 50 48 49 5 0 1
2 1 1 2 8 5 49 50 1 5
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!