POJ 2524-Ubiquitous Religions

深入解析BLheli电调固件与Dshot通讯协议:从原理到实践 本文深入解析了无人机动力系统的核心——BLheli电调固件与Dshot通讯协议。详细阐述了BLheli固件从经典版到BLheli_32的演进及其功能特性,并重点剖析了Dshot数字协议如何通过数据包和校验码实现更快、更准、更可靠的电机控制。文章还涵盖了双向Dshot遥测、实战配置与调参指南,帮助玩家充分释放无人机性能。 阅读详情
Ubiquitous Religions
Time Limit: 5000MS Memory Limit: 65536K
Total Submissions: 37218 Accepted: 17728

Description

There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university believe in. 

You know that there are n students in your university (0 < n <= 50000). It is infeasible for you to ask every student their religious beliefs. Furthermore, many students are not comfortable expressing their beliefs. One way to avoid these problems is to ask m (0 <= m <= n(n-1)/2) pairs of students and ask them whether they believe in the same religion (e.g. they may know if they both attend the same church). From this data, you may not know what each person believes in, but you can get an idea of the upper bound of how many different religions can be possibly represented on campus. You may assume that each student subscribes to at most one religion.

Input

The input consists of a number of cases. Each case starts with a line specifying the integers n and m. The next m lines each consists of two integers i and j, specifying that students i and j believe in the same religion. The students are numbered 1 to n. The end of input is specified by a line in which n = m = 0.

Output

For each test case, print on a single line the case number (starting with 1) followed by the maximum number of different religions that the students in the university believe in.

Sample Input

10 9
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
10 4
2 3
4 5
4 8
5 8
0 0

Sample Output

Case 1: 1
Case 2: 7

Hint

Huge input, scanf is recommended.

就是看用多少连通分量,用并查集很简单,再者如题所说最好用scanf
但是,但是,但是,我没用scanf,哈哈哈哈哈偷笑
#include<iostream>
using namespace std;
int f[50001];//记录每个点的祖先
int find(int x)//寻找该点的祖先
{
	return x==f[x] ? x:find(f[x]);
}
void link(int x,int y)//连接
{
	int fx=find(x);
	int fy=find(y);
	if(fx!=fy)//如果这两点祖先不同,连接起来
		f[fx]=fy;
}
void init(int t)//初始化,方便以后判断
{
	for(int i=1;i<=t;i++)
		f[i]=i;
}
int main()
{
	int m,n,a,b,count,flag=0;
	while(cin>>n>>m)
	{
		flag++;
		count=0;
		if(n==0&&m==0) break;
		init(n);
		for(int i=0;i<m;i++)
		{
			cin>>a>>b;
			link(a,b);
		}
		for(int i=1;i<=n;i++)
		{
			if(f[i]==i) count++;//相等说明这是一个连通分量的起点(最祖先)
		}
		cout<<"Case "<<flag<<':'<<' '<<count<<endl;
	}
	return 0;
}


无监督低照度增强实战:用ZeroDCE和SCI拯救你的夜间照片(附PyTorch代码) 本文深入探讨了无监督低照度图像增强技术,重点解析了ZeroDCE和SCI两大代表性模型的核心原理与实战应用。通过对比分析两者的技术路径、网络结构及性能特点,并附上详细的PyTorch代码实现,旨在帮助读者掌握无需配对数据即可有效提升夜间照片画质的深度学习解决方案。 阅读详情

相关推荐

MySQL服务启动失败?手把手教你排查NET HELPMSG 3534错误(附完整修复流程)

本文针对Windows平台上MySQL服务启动失败并提示NET HELPMSG 3534错误的常见问题,提供了系统性的排查与修复指南。文章深入剖析了错误本质,并手把手教你通过查看MySQL错误日志、检查并初始化数据目录、修正Windows服务配置、排查my.ini配置文件陷阱等核心步骤,彻底解决这一棘手问题,帮助开发者和运维人员快速恢复数据库服务。

wdx0123456的博客 907

【并查集】POJ 2524 Ubiquitous Religions

POJ 2524 Ubiquitous Religions #include <iostream> #include <cstdio> #include <algorithm> #include <queue> #include <cmath> #include <cstring> #include <string&gt...

L_X_ 207

openvas linux/window漏洞扫描和整改

前提:已经安装好openvas 一、添加linux扫描主机 1、Configuration>>Targets 2、添加主机IP 3、主机认证用户和密码 4、扫描任务 5、创建扫描任务 6、添加扫描任务主机,其他默认 7、点击开始扫描 8、扫描完成 9、扫描结果,待整改 二、添加window扫描主机 1、Configuration>>Targets 2、添加主机IP 3、主机认证用户和密码 4、扫描.

友人A的博客 2161

POJ 2524 Ubiquitous Religions

/*********************************** Problem: POJ 2524 Ubiquitous Religions Time: 266MS Memory: 352K Accepted Time: 2009-08-19 20:52:35 Tip: 并查集 http://hi.baidu.com/fandywang_jlu/blog/item/b49e40893...

万猫学社 1万+

WRF-BEM相关参数说明

本参数适用于WRF-BEM模拟武汉市气候。

m0_60013472的博客 1903

智能车竞赛飞檐走壁组立体赛道电磁引导线设计与实现

本文深入解析了智能车竞赛飞檐走壁组立体赛道电磁引导线的核心设计与实现。针对垂直面、圆筒、跷跷板等立体元素,详细阐述了电磁线规格参数选择、三维空间铺设技巧及磁场调试方法,旨在帮助参赛队伍打造稳定可靠的导航系统,提升车模在复杂立体赛道上的通过率与稳定性。

bert9linguist的博客 292

POJ 2524 Ubiquitous Religions 并查集

题意:现在在弄一个大学调查,调查的内容就是,大学生群体的信仰。 如果测试样例输入 1 2 就代表 1 2 拥有同样的信仰。 最后问你最多有多少个不同的 信仰。显然这是一个并查集的题目。而且是模版题目。传送门:POJ-2524-Ubiquitous Religions#include <stdio.h> int pre[50005]; int Find(int x) { int r=x;

知 识 不 是 装 饰。 349

用Python写个彩票小助手:自动生成双色球/大乐透号码并保存到桌面

本文介绍如何使用Python开发一个智能彩票助手,实现双色球和大乐透号码的随机生成与桌面文件保存功能。通过详细的代码示例,包括随机号码生成、文件操作、用户交互和错误处理,帮助Python初学者快速掌握实用工具开发技巧。

weixin_42566121的博客 546

POJ-2524 Ubiquitous Religions

POJ-2524 Ubiquitous Religions 题目链接:POJ-2524 题目大意:给定一对学生编号 即为这两个学生信奉同一份Religions 求一共有多少种Religions 解题思路:并查集 查出一共有多少种结果 完全的模板题 不会请移步并查集详解 代码块: #include<iostream> #include<algorithm> #include...

鱼头的水题之路 233

[统计模型] 基于R的潜在剖面分析(LPA)

本文主要介绍基于R进行潜在剖面分析(Latent Profile Aanalysis, LPA)。 关于潜在类别分析LCA/潜在剖面分析LPA的概念和区别,可以参考一下这篇文章: 潜在类别分析LCA \潜在剖面分析LPA介绍https://www.jianshu.com/p/4c830094131e?utm_campaign=maleskine 但是此文对潜类别分析的阐释还比较生涩,而且没有具体的代码编写、模型优选等内容。本文旨在丰富LPA的内容,并希望和大家交流、共同进步。 1. 什么是潜类别分.

bigstar863的博客 1万+

090、Sensor上电时序与帧同步的驱动级实现——以索尼IMX766为例的AVDD/DVDD/IOVDD时序调优

摘要: 本文以索尼IMX766传感器为例,深入探讨了传感器上电时序与帧同步的驱动级实现问题。通过分析某车载项目量产中的高温黑屏故障,揭示了AVDD/DVDD/IOVDD时序偏差导致传感器内部状态机异常的根源。文章详细解读了IMX766三路电源的时序约束(如AVDD与DVDD需在1ms内同步至90%),并提供了驱动代码级实现方案,包括电源使能顺序、延时控制及帧同步配置。针对多摄同步场景,强调了曝光时间寄存器写入一致性的重要性。最后结合产线问题定位经验,提出通过示波器抓取电源波形验证时序合规性的方法。全文聚焦硬

zzfmlxs的博客 272

poj 2524 Ubiquitous Religions

poj 2524 Ubiquitous Religions Ubiquitous Religions Time Limit:5000MS Memory Limit:65536K Total Submissions:23262 Accepted:11464 Desc...

weixin_30907523的博客 117

python ERA-5气象数据NetCDF格式解析(一)

python ERA-5气象数据NetCDF格式解析

weixin_43896283的博客 2639

poj 2524 Ubiquitous Religions(并查集)

题目链接:poj 2524 Ubiquitous Religions 题目大意:

不慌不忙、不急不躁 846

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

POJ2524 Ubiquitous Religions —— 并查集

题目链接:http://poj.org/problem?id=2524 题解: 找出最多能有多少个不同的宗教,直接并查集就可以了。 第一次提交时没有注意到要输出“Case %d :”, 以后要注意了,细心读题。 代码如下: #include//B - Ubiquitous Religions POJ - 2524 纯并查集 #include #include #inc

A man can be destroyed, but not defeated. 456

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

【POJ2524】Ubiquitous Religions

**Description** 当今世界有很多不同的宗教,很难通晓他们。你有兴趣找出在你的大学里有多少种不同的宗教信仰。 你知道在你的大学里有n个学生(0 < n <= 50000) 。你无法询问每个学生的宗教信仰。此外,许多学生不想说出他们的信仰。避免这些问题的一个方法是问m(0 <= m <= n(n - 1)/ 2)对学生, 问他们是否信仰相同的宗教( 例如他们可能知道他们两个是否去了相同

远方 318

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

Ubiquitous Religions POJ - 2524 并查集

Ubiquitous Religions POJ - 2524 并查集 #include<iostream> #include<algorithm> #define fori for(i=0;i<n;i++) #define fori1 for(i=1;i<=n;i++) #define ll long long const ll mod = 1e9 + 7; ...

ch_huibw的博客 189

poj 2524 Ubiquitous Religions

http://poj.org/problem?id=2524 跟hdu-1213 一样,首先有n个人,然后有m个关系,问属于不同关系的人有多少个。 #include int id[50001],sz[50001],n,m; int find(int p) { while(p!=id[p]) { // 路径压缩,会破坏掉当前节点的父节点的尺寸信息,因为压缩后,当前节点的父节

有一种力量叫乐观 618

POJ 2524-Ubiquitous Religions 并查集

题目来源:http://acm.pku.edu.cn/JudgeOnline/problem?id=2524解题报告:简单的并查集的应用吧#include using namespace std; typedef struct _node { _node* parent; int rank; }node; node **s; void makeSet(int x) { s[x]=new node; s[x]->rank=0; s[x]->parent=s[x]

kindlucy的专栏 786

poj2524 Ubiquitous Religions

照例先上题目 8:宗教信仰 查看提交统计提问 总时间限制: 5000ms 内存限制: 65536kB 描述 世界上有许多宗教,你感兴趣的是你学校里的同学信仰多少种宗教。 你的学校有n名学生(0 输入输入包括多组数据。 每组数据的第一行包括n和m,0 输出对于每组数据,先输出它的编号(从1开始),接着输出学生信仰的

null 1276

POJ 2524——Ubiquitous Religions

原题: Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in

丙三醇 917

POJ 2524, Ubiquitous Religions

并查集 DescriptionThere are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in yo...

weixin_33963189的博客 225
上一篇: SDUT 2139-从起始点到目标点的最短步数
下一篇: HDU 1016-Prime Ring Problem
AC_yang
博客等级 码龄9年 3粉丝 29原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值