ABC142

题目

A.Odds of Oddness

Time:\(1:00\)
Dif:\(\color{Gray}{28}\)

Skip.

B.Roller Coaster

Time:\(2:38\)
Dif:\(\color{Gray}{33}\)

Skip.

C.Go to School

Time:\(4:41\)
Dif:\(\color{Gray}{118}\)

Skip.

D.Disjoint Set of Common Divisors

Time:\(8:52\)
Dif:\(\color{Green}{827}\)

Description

给定两个数 \(a,b\),在他们的公约数集合中选择尽可能多的数使他们两两互质。

Solution

答案就是 \(a,b\) 素公约数的个数。

E.Get Everything

Time:\(15:34\)
Dif:\(\color{Turquoise}{1397}\)

Description

\(N\) 个上锁的宝箱,编号为 \(1\)\(N\)。有 \(M\) 把钥匙,第 \(i\) 把钥匙的代价为 \(a_i\),解锁箱子 \(c_{i,1},c_{i,2},c_{i,3}\ldots c_{i,b_i}\)。问打开所有的箱子的最小代价。
\(1\leq N\leq12,1\leq M\leq1000,1\leq a_i\leq10^5,1\leq b_i\leq N\)

Solution

状压每把钥匙能开的锁,然后做 01 背包即可。方程: $$f_{w_i|j}=\min f_{w_i|j},f_{j}+v_i $$

posted @ 2022-05-13 16:10  1358id  阅读(31)  评论(0编辑  收藏  举报