e-maxx's blog

By e-maxx, 10 years ago, translation, In English

Tutorial for problem "B. Codeforces World Finals"

To solve this problem we had to learn how to check the given date XD.XM.XY for correctness (taking into account number of days in each month, leap years, and so on). After implementing this, we had just to iterate over all 6 possible permutations of three given numbers (BD,BM,BY), checking each of them for correctness as a date, and comparing it with the date of Codeforces World Finals DD.MM.YY. The comparison itself could be done, by simply adding 18 to the year number, and comparing the two dates as a triple (year,month,day).

The only difficult case is the case of February, 29-th. It's easy to understand that the solution described above works correctly, if we suppose that this unlucky man (having its birthday on February 29-th) celebrates his birthday on March, 1st in 3/4 years. Interesting question - what do people usually do in this situation in the real life? :)

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it