In Rashi's second explanation (Bereishit 4:24 שבעים ושבעה) of what Lemech said to his wives, he explains that Lemech didn't kill anyone, but Ada and Tzila were worried because they knew the flood would come and kill all of Kayin's descendants, so they didn't want to have any more children. Lemech argued that he hadn't killed anyone, so if Kayin was given 7 generations, he would be given 77. Rashi says this is a קל וחמר של שטות.
For something so foolish, it was amazingly accurate. Based on the following Rashi, this happened in the year 129, around a year before Sheit was born. Based on Rashi at the beginning of the perek, Kayin and (maybe) Hevel were born before Adam and Chava were thrown out of Gan Eden. Kayin could have killed Hevel as early as the summer of year 1.
Since 7 generations from Kayin ended in 129, 77 generations from Lemech would have ended no later than 129 + (129-1)*11 = 1537. This is 1 year after Hashem decreed the flood (120 years before it happened, 1536).
(Maybe you could play around with the numbers and lose another year. I don't expect to be able to identify all the steps needed to make numbers come out exact unless I'm the Gr"a, which I'm not.)
I made some assumptions of when Kayin killed Hevel, but 1537 is an upper limit on when the 77 generations could have ended. Lemech really did get 77 generations before the decree, and even more before his descendents were actually killed.
Where's the שטות?