GCDs

From programming_contest
Revision as of 19:34, 9 March 2024 by Kmk21 (talk | contribs) (Created page with "realization: only a small total count of GCDs. moreso, any range that spans coprime numbers will be 1. or more generally, all numbers in that range must be divisible by the GCD, and no higher number. So go through each number, track the earliest seen number which is divisible by each possible GCD (max 100). O(100*100k) Category:ICPC Problems Category:Nac2014 Category:Algorithm Medium Category:Math Category:GCD Category:Dynamic Programming")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

realization: only a small total count of GCDs. moreso, any range that spans coprime numbers will be 1. or more generally, all numbers in that range must be divisible by the GCD, and no higher number.

So go through each number, track the earliest seen number which is divisible by each possible GCD (max 100). O(100*100k)