Fireball's damage is divided as Fireball resolves, not as it's cast, because there are no choices involved. The division involves only targets that are still legal as Fireball resolves.

Artwork
Loading artwork…
Fireball
30th Anniversary Edition · #145 · EN
Nonfoil—Foil—
Card rules
This spell costs 1 more to cast for each target beyond the first.
Fireball deals X damage divided evenly, rounded down, among any number of targets.
Common · Illustrated by Mark Tedin
Format legality
Commander Legal
Duel Legal
Legacy Legal
Modern Legal
Oathbreaker Legal
Pauper Legal
Pauper Commander Legal
Penny Legal
PreDH Legal
Premodern Legal
Tlr Legal
Vintage Legal
Alchemy Not Legal
Brawl Not Legal
Competitive Brawl Not Legal
Future Not Legal
Gladiator Not Legal
Historic Not Legal
Old School Not Legal
Pioneer Not Legal
Standard Not Legal
Standard Brawl Not Legal
Timeless Not Legal
Rulings
Published rulings from the downloaded Scryfall catalog. Source card record · Rules and interactions
For example, if X is 5 and you choose three target creatures, Fireball has a total cost of 7
(even though its mana cost is just 5
and its mana value is 6). If those creatures are all still legal targets as Fireball resolves, it deals 1 damage to each of them.
You may cast Fireball with zero targets, regardless of the value chosen for X. If you do so, it will not be a targeted spell, and no damage will actually be dealt when it resolves.
You can target more than X creatures. However, if the number of legal targets at the time Fireball resolves is greater than X, none of them will be dealt any damage.