CodeLakVN's blog

By CodeLakVN, history, 5 hours ago, In English

Hi, please help me to solve this problem. Given a graph with N (<= 2e5) vertices (1..N). Between 2 vertices i and j will have an edge if i < j and gcd(i, j) > 1. The value of node i is a[i] (<= 1e9). We have to find a set of nodes S, such that for each any 2 nodes x and y in S, there is no edge between them, and the total value of nodes in S is maximum. For example: we have N = 6 nodes, and a[6] = {1, 2, 1, 3, 1, 6}, then S will be {1, 5, 6} then the total value of S is 1 + 1 + 6 = 8 is as maximum as possible

  • Vote: I like it
  • -4
  • Vote: I do not like it