When the comet approaches the planet by the following conditions, I picked up the planet name, the distance, and time.
The Earth is less than 0.5AU, The Jupiter and Saturn are less than 1AU, The Uranus and Neptune are less than 0.5AU, Other planets are less than 0.05AU.