100 likes | 212 Views
In the HKOI2010 Junior Q4 problem "Insect Galore," we explore four types of insects active in various years: bees, cicadas, beetles, and butterflies. The challenge is to determine the earliest year in which all four insect types can be observed together. Each type has distinct active years, and the solution hinges on tactical observation and simulation of their appearances. Using mathematics, we analyze combinations of insect appearances to identify the year that allows seeing the maximum number of insects. The final answer is derived through careful consideration of their overlapping activity years.
E N D
Solution for HKOI2010 Junior Q4 By Gary Sham Insect Galore豐富的昆蟲
Problem Description • Given 4 kinds of insects with different number and year of activity. • Find the earliest year that can observe most insects. • Bees = 2001, 2003, 2005 etc. • Cicadae = 2002, 2005, 2008 etc. • Beetles = 2001, 2002, 2005, 2006 etc. • Butterflies = 2001, 2003, 2006, 2010 etc. • E.g. {2 4 1 0}, answer = 2017 7 • 2017 is the earliest year that can see all insects.
Statistic • #Attempts 46 • #Maximum 100 • #Maximum 5 • #Mean (Attempted) 25.3 • #Minimum 0 • #Std Dev (Attempted) 32.5
Question • How to know which kind of insects will appear that year? • Mathematics • Or simulation and array. • Another question : When to stop??
Observation • There are only 16 states of activity of insects. • Save the result of all states? • Do all states must appear at some time? • The total number of insects must be the sum of them. • If yes......
Solution1 year = 2010, Max = 0 While (true) do sum = 0 if (BEE && Cicadae && Beetles && Butterflies) sum+=BEE+Cicadae+Beetles+Butterflies; if (sum>max) output, break; Time Complexity: ??? Expected score: 50
In fact…… • NO! • The problem is Butterflies. • Butterflies and Cicadae will not appear at the same time. • Prove by Mathematics.
Full Solution • For each state, there are only one answer: YEAR and HOW TO ADD THE NUMBER will not change. Hardcode • We have to consider whether we choose Butterflies or Cicadae. • Maximum 2021 • Time Complexity: O(1) • Expected Score: 100
Skills • Observation • Mathematics • Hardcode