- 1、本文档共3页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
通过率:47% 难度:一般
Ubiquitous Religions
Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 11902 Accepted: 5609
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
Case 1: 1
Case 2: 7
翻译:现如今世界上有如此多的宗教信仰,要将它们所有的都保持联系是非常困难的。你对于找出在一个大学里面同学们有多少不同的宗教信仰感兴趣。
你知道这个大学里面有 n 个学生。如果让你去一个一个问每一个学生的宗教信仰是不可能的。而且,许多学生不愿意表露他们的宗教信仰。有个方法可以避免这个问题,就是去问 m
(0=m=n(n-1)/2)对学生,并且问它们是否同一个宗教信仰(比如说如果他们是同一个宗 教信仰,他们也许相互认识)。对于这个数据,你可能并不知道吗,每一个学生的信仰,但 是你可以知道最多有多少个不同的宗教信仰在这个校园里面。你可以假设每一个学生有至多 一个宗教信仰
输入数据包括情况的数目,每一种情况包括有数据 n 和 m,接下来的 m 行包括了两个数据i 和 j,表示学生 i 和 j 是同一个宗教信仰。学生是从 1 到 n 编号的,若 n=0 并且 m=0 则表示输入结束
对于每一种情况,显示
您可能关注的文档
- PEP小学英语五年级下册教学片段设计.docx
- PEP小学英语五年级下册句子复习(汉译英).docx
- PEP小学英语五年级下二单元复习课教学设计教案资料.docx
- pep小学英语音标练习.docx
- PEP小学英语语音资料.docx
- pep英语四年级下册第6单元教学设计新部编版.docx
- Permanent Magnets Design and Magnetic Field Analysis of Multidisc Coreless Permanent Magnet Synchro分析和总结分析和总结.docx
- PET核心词汇21天分析和总结.docx
- PE袋初包装封口验证报告.docx
- PE工程师试题答案(精华).docx
最近下载
- 2025年河南建筑职业技术学院单招职业适应性测试题库(满分必刷).docx VIP
- 2024年高考(新高考1卷、2卷、全国甲卷)小说阅读真题讲评(结合近四年命题规律).pptx VIP
- 2024年华远国际陆港集团所属企业招聘考试真题.docx VIP
- 17J008 挡土墙(重力式、衡重式、悬臂式)(最新).pdf
- 铁路巡防员培训课件.pptx
- 2024年高考(新高考1卷、2卷、全国甲卷)语言文字运用真题讲评(结合近四年命题规律).pptx VIP
- 江苏省建设工程监理现场用表(第六版修订版).doc VIP
- TZOIA-硅光电倍增管性能测试方法.pdf
- 第2版《植物学》配套题库(考研真题+章节题).pdf
- 2024年山西省华远国际陆港集团专业技术人员招聘考试真题.docx VIP
文档评论(0)