Presentation is loading. Please wait.

Presentation is loading. Please wait.

Solution for HKOI2010 Junior Q4 By Gary Sham. Problem Description  Given 4 kinds of insects with different number and year of activity.  Find the earliest.

Similar presentations


Presentation on theme: "Solution for HKOI2010 Junior Q4 By Gary Sham. Problem Description  Given 4 kinds of insects with different number and year of activity.  Find the earliest."— Presentation transcript:

1 Solution for HKOI2010 Junior Q4 By Gary Sham

2 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.

3 Statistic  #Attempts 46  #Maximum 100  #Maximum 5  #Mean (Attempted) 25.3  #Minimum 0  #Std Dev (Attempted) 32.5

4 Question  How to know which kind of insects will appear that year?  Mathematics  Or simulation and array.  Another question : When to stop??

5 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......

6 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

7 In fact……  NO!  The problem is Butterflies.  Butterflies and Cicadae will not appear at the same time.  Prove by Mathematics.

8 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

9 Skills  Observation  Mathematics  Hardcode

10 END


Download ppt "Solution for HKOI2010 Junior Q4 By Gary Sham. Problem Description  Given 4 kinds of insects with different number and year of activity.  Find the earliest."

Similar presentations


Ads by Google