1 / 10

Insect Galore 豐富的昆蟲

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.

ranger
Télécharger la présentation

Insect Galore 豐富的昆蟲

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Solution for HKOI2010 Junior Q4 By Gary Sham Insect Galore豐富的昆蟲

  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

More Related