lightoj1149 - Factors and Multiples【二分图最大匹配】

本文介绍了一种算法解决两个整数集合中元素的整除问题,通过移除最少数量的元素使得任一集合中的元素都不成为另一集合元素的倍数。文章提供了完整的代码实现,并通过样例展示了算法的有效性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


1149 - Factors and Multiples
Time Limit: 2 second(s)Memory Limit: 32 MB

You will be given two sets of integers. Let's call them set A and set B. Set A contains n elements and set B contains m elements. You have to remove k1 elements from set A and k2 elements from set B so that of the remaining values no integer in set B is a multiple of any integer in set Ak1 should be in the range [0, n] and k2 in the range [0, m].

You have to find the value of (k1 + k2) such that (k1 + k2) is as low as possible. P is a multiple of Q if there is some integer K such that P = K * Q.


Suppose set A is {2, 3, 4, 5} and set B is {6, 7, 8, 9}. By removing 2 and 3 from A and 8 from B, we get the sets {4, 5} and {6, 7, 9}. Here none of the integers 6, 7 or 9 is a multiple of 4 or 5.

So for this case the answer is 3 (two from set A and one from set B).

Input

Input starts with an integer T (≤ 50), denoting the number of test cases.

The first line of each case starts with an integer n followed by n positive integers. The second line starts with m followed by m positive integers. Both n and m will be in the range [1, 100]. Each element of the two sets will fit in a 32 bit signed integer.

Output

For each case of input, print the case number and the result.

Sample Input

Output for Sample Input

2

4 2 3 4 5

4 6 7 8 9

3 100 200 300

1 150

Case 1: 3

Case 2: 0


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=110;
int n,m;
int p[maxn];
int numa[maxn];
int numb[maxn];
bool vis[maxn];
bool find(int k){
	for(int i=0;i<m;++i){
		if(!vis[i]&&numb[i]%numa[k]==0){
			vis[i]=true;
			if(p[i]==-1||find(p[i])){
				p[i]=k;
				return true;
			}
		}
	}
	return false;
}
int main()
{
	int i,j,k=1,t;
	scanf("%d",&t);
	while(t--){
		scanf("%d",&n);
		for(i=0;i<n;++i){
			scanf("%d",&numa[i]);
		}
		scanf("%d",&m);
		for(i=0;i<m;++i){
			scanf("%d",&numb[i]);
		}
		int ans=0;
		memset(p,-1,sizeof(p));
		for(i=0;i<n;++i){
			memset(vis,false,sizeof(vis));
			if(find(i))ans++;
		}
		printf("Case %d: %d\n",k++,ans);
	}
	return 0;
}


内容概要:本文详细探讨了智慧医疗建设的历程、现状、挑战及未来发展趋势。智慧医疗建设经历了信息化、数字化和数智化三个阶段,政策、需求和技术是其发展的三大推动力。文章指出,当前智慧医疗已从数据收集与治理阶段迈向数据价值应用阶段,特别是在高质量数据库建设、云计算、人工智能等技术的推动下,实现了临床科研、药物研发、真实世界研究及数字营销等多个场景的商业化落地。此外,文中还分析了医疗信息化系统同质化、数据孤岛、互联互通等痛点,并提出了云化转型、新产品、新技术和新服务作为突破方向。最后,通过奈特瑞、医渡科技、东软集团三个企业案例,展示了不同企业在智慧医疗领域的创新实践。 适合人群:医疗信息化从业者、医疗行业研究人员、医疗机构管理者、医疗科技企业相关人员、政策制定者及对智慧医疗感兴趣的投资者。 使用场景及目标:①了解智慧医疗建设的阶段性特征和发展趋势;②掌握医疗信息化建设中的关键技术和应用场景;③探讨解决医疗信息化系统同质化、数据孤岛等问题的策略;④学习企业如何通过新产品、新技术和新服务实现突破,推动智慧医疗发展。 其他说明:本文通过对智慧医疗建设的深入剖析,强调了政策导向、技术创新和市场需求的重要性,为企业和政策制定者提供了宝贵的参考。同时,文章也揭示了未来智慧医疗发展的广阔前景,特别是在数据资产化和数智化应用方面的巨大潜力。阅读时应注意结合政策背景和技术发展趋势,关注行业动态和企业创新实践。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值