Multiset that allows GCD queries?

Revision en1, by bihariforces, 2023-02-02 11:51:27

How would we implement a multiset data structure that allows insertion, deletion and querying GCD of values currently present in multiset?

GCD() -> 5
GCD() -> 5
GCD() -> 10

This question is not from some existing problem and was just wondering if it was possible to have such data structure where deletion is possible on operations like GCD. I believe this would be helpful but can't understand how we would apply this or maybe some other method which would work for large numbers upto 1e18.

Tags data structures, gcd, multiset, query


  Rev. Lang. By When Δ Comment
en1 English bihariforces 2023-02-02 11:51:27 643 Initial revision (published)