fork download
  1. s=$3{for(y=$1;(x=y*$2+1)%s||$1<x/=s;y--);print x,y}
Success #stdin #stdout 0s 5316KB
stdin
1 1 1
stdout
1 0